Code Monkey home page Code Monkey logo

aws-sdk-unity's Introduction

AWS Mobile SDK for Unity

NOTE

The aws sdk for unity is now distributed as a part of aws sdk for dotnet. Please refer the new repository for more information.

aws-sdk-unity's People

Contributors

albertvaka avatar karthiksaligrama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-sdk-unity's Issues

Namespace ambiguity

The Cognito package failed to compile when I first imported it into my project. The errors were as follows:

Assets/AWSUnitySDK/AWSCore/AWSConfigs.bcl.cs(72,20): error CS0117: `Logger' does not contain a definition for `ClearLoggerCache'
Assets/AWSUnitySDK/AWSCore/AWSConfigs.bcl.cs(102,20): error CS0117: `Logger' does not contain a definition for `ClearLoggerCache'
Assets/AWSUnitySDK/AWSCore/Amazon.Runtime/AbstractWebServiceClient.cs(153,38): error CS0117: `Logger' does not contain a definition for `EmptyLogger'
Assets/AWSUnitySDK/AWSCore/Amazon.Runtime/AbstractWebServiceClient.cs(155,38): error CS0117: `Logger' does not contain a definition for `GetLogger'

This was a problem because Logger is a very common name for a class, and I already had my own Logger class in the global namespace. While this happened for me with Logger, I'm sure that there are other classes that will be just as vulnerable (though not as likely).

AmazonS3Client client missing implementation of GetObjectMetadata

The S3Client is missing implementation of GetObjectMetaData. Just for getting the metadata values , i dont want to donwload the whole object. I tried implementing it on my own and here is the code:

public void GetObjectMetadata(GetObjectMetadataRequest request,AmazonServiceCallback callback,object state)
{

        if (!AmazonInitializer.IsInitialized)
            throw new Exception ("AWSPrefab is not added to the scene");

        ThreadPool.QueueUserWorkItem (new WaitCallback (delegate
                                                        {
            var marshaller = new GetObjectMetadataRequestMarshaller();
            var unmarshaller =  GetObjectMetadataResponseUnmarshaller.GetInstance();
            Invoke (request, callback, state, marshaller, unmarshaller, signer);
        }));
        return;
    }

But this gives [AmazonS3] ERROR: 403 Forbidden
Although GetObject works perfectly fine. Can you plese help me out here urgently?!

sqlite3 not found

I'm getting this error.

DllNotFoundException: sqlite3
Amazon.Unity3D.Storage.SQLiteDatabase..ctor (System.String dbPath) (at Assets/AWSUnitySDK/AWSCore/Amazon.Unity3D/Storage/SQLiteDatabase.cs:159)
Amazon.Unity3D.Storage.SQLiteKVStore.SetupDatabase (System.String dataPath) (at Assets/AWSUnitySDK/AWSCore/Amazon.Unity3D/Storage/SQLiteKVStore.cs:43)
Amazon.Unity3D.Storage.SQLiteKVStore..cctor () (at Assets/AWSUnitySDK/AWSCore/Amazon.Unity3D/Storage/SQLiteKVStore.cs:28)
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Amazon.Unity3D.Storage.SQLiteKVStore
Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String unAuthRoleArn, System.String authRoleArn, Amazon.CognitoIdentity.AbstractCognitoIdentityProvider cibClient, IAmazonSecurityTokenService stsClient) (at Assets/AWSUnitySDK/AWSCore/Amazon.CognitoIdentity/CognitoAWSCredentials.cs:138)
Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String identityPoolId, Amazon.RegionEndpoint region)
CognitoSyncClientManager.init () (at Assets/aws/CognitoSyncClientManager.cs:46)

Using unity 5 and windows 8.

SQL data field access

Would you be open to allowing access to a few more of the fields in the database? In particular, I'm working on managing the timing of syncs to the cloud. If the data was synced within the last x seconds, I will ignore the client request to force a sync.

The database has properties for "last_sync_timestamp", and "last_sync_result". They are not public properties, so can not be checked by my code. The result field seems to actually not be in use, but I'm guessing it will be at some point.

There are probably some other useful fields too, but I'll start with those.

Thanks

Is there an easy way to use the S3 part of the plugin to target a cloudfront distribution(pointing towards an s3 origin)?

From what i have figured in the short time i've been messing with the unity sdk, by default(i guess trying to be more user friendly), the constructor for the s3client only gets bucket as a name, and then it formats itself in a url. Is there anyway to skip this, and either use a normal url in the constructor without it being altered to add endpoints or disable the url parsing somewhere? I'm guessing that would be the only thing needed for it work since cloudfront forwards everything to s3.Thanks a lot.

Can't change user login after the Credentials have been initiated once!

In a scenario where CognitoAWSCredentials has been initialized and after that a user logs in using public auth like facebook , IdentityProvider.RefreshAsync doesn't actually changes the identity as there is a check " if (!IsIdentitySet) " in refresh async override function in AmazonCognitoEnhancedIdentityProvider , which stops in getting the identity linked to that particular FB account.

NullReferenceException of Analytics with Unity iOS-64bit build (IL2CPP scripting backend)

Open AmazonMobileAnalyticsSample.
In Player Settings, change iOS Scripting Backend to IL2CPP.
Build project to export a 64-bit xcode project.
Debug the project on an iOS device from XCode.
The app will generate an exception when it tries to send records to AWS analytics service.

Unity version: 4.6.3 p1
iOS: 8.1.3
Model: iPad4,1
Date: Mon Mar 03 05:40:11 GMT-08:00 2015

NullReferenceException: A null value was found where an object instance was required.
at Mono.Globalization.Unicode.SimpleCollator+Context..ctor (CompareOptions opt, System.Byte* alwaysMatchFlags, System.Byte* neverMatchFlags, System.Byte* buffer1, System.Byte* buffer2, System.Byte* prev1, Boolean quickCheckPossible) [0x00000] in :0
at Amazon.Runtime.Internal.Transform.WWWRequestData.FireRequest () [0x00000] in :0
at Amazon.Unity3D.AmazonMainThreadDispatcher+c__Iterator1.MoveNext () [0x00000] in :0
at Replacements.RemotingServices.CreateClientProxy (System.Type objectType, System.String url, System.Object[] activationAttributes) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine_Auto (IEnumerator routine) [0x00000] in :0
at UnityEngine.MonoBehaviour.StartCoroutine (IEnumerator routine) [0x00000] in :0
at Amazon.Unity3D.AmazonMainThreadDispatcher.Update () [0x00000] in :0
at Replacements.RemotingServices.CreateClientProxy (System.Type objectType, System.String url, System.Object[] activationAttributes) [0x00000] in :0
Replacements.RemotingServices:CreateClientProxy(Type, String, Object[])
UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Amazon.Unity3D.AmazonMainThreadDispatcher:Update()
Replacements.RemotingServices:CreateClientProxy(Type, String, Object[])

(Filename: currently not available on il2cpp Line: -1)

Geospatial Indexing support in Unity SDK?

We need a backend that can store geo points with an object and then query objects based on that data. It sounds like geospatial indexing is the AWS solution for this. It this possible with the Unity SDK? If not, will it be added soon?

This is a critical piece, in our consideration of AWS.

Exception with IL2CPP Scripting Backend

This is an exception with iOS 64-bit build:

Unity version: 4.6.2 p2
iOS: 8.1.3
Model: iPad4,1
Date: Mon Mar 02 08:50:15 GMT-08:00 2015

NotSupportedException: Tools/il2cpp/il2cpp/libil2cpp/os/Posix/LibraryLoader.cpp(16) : Unsupported internal call for IL2CPP:LibraryLoader::LoadDynamicLibrary - "PInvoke is not yet supported on Posix platforms."
at Amazon.MobileAnalyticsManager.Delivery.Internal.SQLiteEventStore.GetDatabaseSize () [0x00000] in :0
at Amazon.Unity3D.Storage.SQLiteDatabase.sqlite3_open (System.String filename, IntPtr& db) [0x00000] in :0
at Amazon.Unity3D.Storage.SQLiteDatabase..ctor (System.String dbPath) [0x00000] in :0
at Amazon.Unity3D.Storage.SQLiteKVStore.SetupDatabase (System.String dataPath) [0x00000] in :0
at Amazon.Unity3D.Storage.SQLiteKVStore..cctor () [0x00000] in :0
at Replacements.Attribute.CheckParameters (System.Object element, System.Type attributeType) [0x00000] in :0
at Amazon.RootConfig..ctor () [0x00000] in :0
at Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String unAuthRoleArn, System.String authRoleArn, Amazon.CognitoIdentity.AbstractCognitoIdentityProvider idClient, IAmazonSecurityTokenService stsClient) [0x00000] in :0
at Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String identityPoolId, Amazon.RegionEndpoint region) [0x00000] in :0
at AmazonMobileAnalyticsSample.Start () [0x00000] in :0
at Replacements.Attribute.CheckParameters (System.Object element, System.Type attributeType) [0x00000] in :0
Rethrow as TypeInitializationException: The type initializer for 'Amazon.Unity3D.Storage.SQLiteKVStore' threw an exception.
at Amazon.RootConfig..ctor () [0x00000] in :0
at Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String unAuthRoleArn, System.String authRoleArn, Amazon.CognitoIdentity.AbstractCognitoIdentityProvider idClient, IAmazonSecurityTokenService stsClient) [0x00000] in :0
at Amazon.CognitoIdentity.CognitoAWSCredentials..ctor (System.String identityPoolId, Amazon.RegionEndpoint region) [0x00000] in :0
at AmazonMobileAnalyticsSample.Start () [0x00000] in :0
at Replacements.Attribute.CheckParameters (System.Object element, System.Type attributeType) [0x00000] in :0
Replacements.Attribute:CheckParameters(Object, Type)

(Filename: currently not available on il2cpp Line: -1)

Access modifiers

Would you all mind updating the access modifiers on fields in your virtual, override, and abstract classes so we can override them? For example, if I want to create my own sync manager, I'd likely override the DefaultCognitoSyncManager and override a few methods. I found that I couldn't create an override for OpenOrCreateDataset() because remote, local, cognitoCredentials, and GetIdentityId() are all private. Protected would let me use them.

I'm sure there are other examples too, in places like DefaultDataset and elsewhere.

Thanks.

JSON encoding error when enqueuing Mobile Analytics events

I'm using aws-sdk-unity 1.0.5 on Unity 5.0.1.f1, and Mobile Analytics is not working at all on iPhone hardware. I did some digging, and tracked the error down to AmazonMADefaultDeliveryClient. EnqueueEventsForDelivery:

        public void EnqueueEventsForDelivery(Amazon.MobileAnalytics.Model.Event eventObject)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate 
            {   
                string eventString = JsonMapper.ToJson(eventObject);

The JsonMapper.ToJson() call throws an exception:

[MobileAnalyticsDeliveryClient] ERROR: Exception encoding event _session.start to JSON: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper delegate-invoke) System.Reflection.MonoProperty/Getter`2<Amazon.MobileAnalytics.Model.Event, System.Collections.Generic.Dictionary`2<string, string>>:invoke_Dictionary`2<string, string>__this___Event (Amazon.MobileAnalytics.Model.Event)' while running with --aot-only.

  at System.Reflection.MonoProperty.GetterAdapterFrame[Event,Dictionary`2] (System.Reflection.Getter`2 getter, System.Object obj) [0x00000] in <filename unknown>:0 
  at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <filename unknown>:0 
  at ThirdParty.Json.LitJson.JsonMapper.WriteValue (System.Object obj, ThirdParty.Json.LitJson.JsonWriter writer, Boolean writer_is_private, Int32 depth) [0x00000] in <filename unknown>:0 
  at ThirdParty.Json.LitJson.JsonMapper.ToJson (System.Object obj) [0x00000] in <filename unknown>:0 
  at Amazon.MobileAnalyticsManager.Delivery.AmazonMADefaultDeliveryClient+<EnqueueEventsForDelivery>c__AnonStorey77.<>m__96 (System.Object ) [0x00000] in <filename unknown>:0

I'll see if I can patch this, but if anyone has any ideas in the meantime, I'd love to hear them.

Documentation and example inconsistencies/incompleteness for Cognito

I was looking at Facebook authentication some more and noticed that the Unity SDK guide says to use credentials.IdentityProvider.Logins.Add ("graph.facebook.com", "facebook_token");, but the AWS Cognito sample uses credentials.AddLogin(authProvider, accessToken);.
Additionally, there is no mention of needing to call credentials.GetCredentialsAsync(serviceCallback, null) in the Unity SDK guide, although the sample code does so. I was attempting to use credentials.IdentityProvider.RefreshAsync(), but this didn't seem to trigger the identity to update/merge post-Facebook linking. This standalone example doesn't seem to be a complete one as I can't determine where it's actually adding the Facebook login to the IdentityProvider, although it does use RefreshAsync() when the FB login succeeds.

Personally, these inconsistencies have made it difficult to track down issues at times. I know the SDK for Unity is still in Developer Preview status, but I hope that updating and unifying documentation and code samples will be made a priority soon. Thanks!

403 Forbidden

Hello , I am getting this issue:
on Synchronize () or RefreshDatasetMetadataAsync() we get the a 403 Forbidden Error.

"WebException: 403 Forbidden
Rethrow as AmazonServiceException: 403 Forbidden
Rethrow as DataStorageException: Failed to list records in dataset: Account"

Unity:4.6.3f1
Os:Windows 8.1 pro

And this is my curl response:
{"message":"The request signature we calculated does not match the signature you
provided. Check your AWS Secret Access Key and signing method. Consult the serv
ice documentation for details.\n\nThe Canonical String for this request should h
ave been\n'GET\n/identitypools/us-east-1%3Adddbd6ae-e9ae-4be7-a385-f0c44a279f22/
identities/us-east-1%3A67aa6ec6-310c-4f0c-9a15-d01406580d68/datasets/PlayerInfo/
records\nlastSyncCount=0\nhost:cognito-sync.us-east-1.amazonaws.com\nuser-agent:
AWS-SDK-UNITY/1.0.5\nx-amz-content-sha256:44136fa355b3678a1146ad16f7e8649e94fb4f
c21fe77e8310c060f61caaff8a\nx-amz-date:20150410T101458Z\nx-amz-security-token:AQ
oDYXdzEFsa4ARMSNIsJwPdpxCJ00lrSg5uqgQHOdvQk8l496BnNO639LL9UMK1Q7342h+SVKJoSITh70
2/eaOUMaRUMx94JNLNKm0X1YcN84lQm54bUrw9xp3Y4Nf0AfXqx6SGtPsZtl85vn7+eqE+/AdVXdaaLM
3Iod5KxbI4UW2/s10AX5YDYpDhR/MnafMzytBePO8rSJQJYPx16TS8Crs08gkDIB+RBwmMsj2y0nWvQb
s1fF0ELTnhSVgyWvRtnAjbMXPkk0hfHfptlyDaV94gPg39zuWzHXN4LYkwsrjsw8lFzLKDhSwf37Se2Z
3u0XrO5+OnWV9xP4yHInxcJNyy5MV+n6Fjc3UR4KX1uV3X45rO4g6p6dOWVTwwRo55CwFEsi73W5elOK
NjWAG+CZxyza/nC7dVysjEiFyxN+k2sjMsw2k6kiKe7/8qdbP9sVmghE8VDKDfL+5cvgBwnANo+ptwQY
6G6ING0+0YATxJpB8M4rPm14rkvtzJuJU9E578dt0Pc18H+aR/gqsro6o9LoNpq0ly12fgWWlPMy5xZB
3Q0mnakJPzGPVlKakwv3e1DEoboFEtGs8ZYyBMAH9GmK+OQb7QW9KP2grdMuoH87RA8s0HyO1gh6lYYv
k86ypcGzwJyrZm8zfCjARFApHQ6HWoT0Pwz8ekw0geMLZnDF5eVtxa8ffsi+5AwZLW6qM6Fm4PhwfD4D
CGNrx2uhcT5tXhy14z0DGuqHk5NweKdkwOQcnXUj6rekk1/MPghH7UBfhaauXtT8F9vMV2cR+caZl/u5
GasF0VZLtA4QgKgAuxcbqU2SDgvp6pBQ==\nx-http-method-override:GET\n\nhost;user-agen
t;x-amz-content-sha256;x-amz-date;x-amz-security-token;x-http-method-override\n4
37da515a768a74bdc5d9c67803dfe8e3f0339ebad2e87474f5d3fde0427bd80'\n\nThe String-t
o-Sign should have been\n'AWS4-HMAC-SHA256\n20150410T101458Z\n20150410/us-east-1
/cognito-sync/aws4_request\n39571a63dd507046bd6019cd89951dc7ba615e980a3068f0f73e
1788d025b81e'\n"}

NOTE: This happens only for Auth users( i am using Facebook auth) .. for guest users (unauth) it works fine.

Bad Request error with _context.LoadAsync

I'm not sure if this is an error on my part or on the SDK, but I continuously get a "Bad Request" error when trying to using the LoadAsync Method. Below I've inserted my method for initializing the client/context and the method call.

_dynamoClient = new AmazonDynamoDBClient(CognitoSyncClientManager.CognitoAWSCredentialsInstance,RegionEndpoint.USEast1);
_context = new DynamoDBContext(_dynamoClient);

_context.LoadAsync(id, LoadUserData, null);

Support HTTPS for S3 posts

Hi,

We're looking at using S3 directly from our Unity clients, and functionally the code I've written works fine, except that it fails to post when behind certain proxies (such as our work one!).

A simple way to avoid this problem in many cases is to support HTTPS for S3 posts. To confirm this works I've hardcoded it in, and it works fine. If necessary I can make a pull request for you with a full end to end code change, but I'm not sure how you'd want this functionality to be exposed.

Many thanks,
Jeremy

Where is the mapped class for Cognito (like DynamoDB has), and what should we do if no connection initially?

In the developer guide for DynamoDB for .NET, http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ArbitraryDataMappingHLAPI.html, you're able to create a mapped DynamoDB class incredibly easily like,

[DynamoDBTable("ProductCatalog")]
public class Book
{
    [DynamoDBHashKey]   // hash key
    public int Id { get; set; }

    [DynamoDBProperty]
    public string Title { get; set; }

    [DynamoDBProperty]
    public string ISBN { get; set; }
    // Multi-valued (set type) attribute. 

    [DynamoDBProperty("Authors")]
    public List<string> BookAuthors { get; set; }

    // Arbitrary type, with a converter to map it to DynamoDB type.
    [DynamoDBProperty(typeof(DimensionTypeConverter))]
    public DimensionType Dimensions { get; set; }
}

Which, while incredibly useful for DynamoDB, to me, that would make a whole lot more sense for a Cognito backed class, something like,

[CognitoDataset("ProductCatalog")]
public class Book
{
    [CognitoProperty]
    public int Id { get; set; }

    [CognitoProperty]
    public string Title { get; set; }

    [CognitoProperty]
    public string ISBN { get; set; }
    // Multi-valued (set type) attribute. 

    [CognitoProperty("Authors")]
    public List<string> BookAuthors { get; set; }

    // Arbitrary type, with a converter to map it to DynamoDB type.
    [CognitoProperty(typeof(DimensionTypeConverter))]
    public DimensionType Dimensions { get; set; }
}

Or similar. Reason I'm saying this is because I've basically written a kind of custom version of this already, because I didn't think this existed within your SDK already, but seeing it for DynamoDB, but not Cognito doesn't make a whole lot of sense to me.

And my second question. In testing, if you turn off network connectivity the very first time, you don't have access to a Dataset to store anything. We plan on having a Cognito Dataset as the complete backend of a user's profile, whether they're online, or offline (obviously they can only sync when online), but I'm completely confused as to what to do if they don't have a network connection the very first time they launch the app, before they've even a cached cognito id.

AmazonCognitoIdentityProvider Refresh causes crash after app redirects from url.

Hi,

My application connects to several third-party services through OAuth and every time the app re-opens utilizing iOS's custom url scheme and redirect urls it crashes with the error below. I've tried a lot of different work arounds including clearing the callback queue, but none have worked.

Thanks for your help!

Unhandled Exception: Amazon.Runtime.AmazonClientException: columns identity_id, dataset_name, key are not unique
at Amazon.Unity.Storage.SQLiteStatement.Step () [0x00000] in :0
at Amazon.CognitoSync.SyncManager.Storage.SQLiteLocalStorage.ChangeIdentityId (System.String oldIdentityId, System.String newIdentityId) [0x00000] in :0
at Amazon.CognitoSync.SyncManager.DefaultCognitoSyncManager.IdentityChanged (System.Object sender, System.EventArgs e) [0x00000] in :0
at (wrapper delegate-invoke) System.EventHandler`1<Amazon.CognitoIdentity.IdentityChangedArgs>:invoke_void__this___object_IdentityChangedArgs (object,Amazon.CognitoIdentity.IdentityChangedArgs)
at Amazon.CognitoIdentity.AbstractCognitoIdentityProvider.UpdateIdentity (System.String newIdentityId) [0x00000] in :0
at Amazon.CognitoIdentity.AmazonCognitoIdentityProvider+c__AnonStorey1D.<>m__9 (Amazon.Runtime.AmazonServiceResult result) [0x00000] in :0
at Amazon.Unity.AmazonMainThreadDispatcher+AmazonServiceCallbackState+c__Iterator2.MoveNext () [0x00000] in :0

Is there a way to get the current Date and UTC time from the cloud?

This may be a stupid question, and i apologize if it is, but I need a reliable way to know the date and time in my game, and i thought you may already have the soulution.
Currently i am using System.DateTime.UtcNow, but it is easily exploitable.

Sorry again, and thank you.

Null reference in ProcessHttpResponse

Hi again,

I just wanted to let you know, it is sometimes possible for AmazonWebServiceClient's ProcessHttpResponse to have a null asyncResult which can cause the app to crash on iOS. So for anyone who has the issue, put an null check around it like so:

if (asyncResult != null)
{
    asyncResult.IsCompleted = true;
    asyncResult.InvokeCallback();
}

Unity AWS assemblies

Would it be possible for future releases to provide both the source and the assemblies? We have run into some issues with large CSharp libraries generated by Unity and find that having elements in separate dlls reduces the issue.

Thanks

Table.Query problem.

I'm currently working on an iOS app in Unity, and querying a table for messages. When I query the table the first time, the search that is returned by Table.Query is valid, and all the appropriate results are returned. The second time I call Table.Query, your logging does not show that a WWW request has been made or completed. Nothing is returned and search.Count does not contain a value. I am not using the async version of the call, and I'm executing the request inside of a thread.

Some things to note: I'm using Search.Count as a loop condition instead of Search.IsDone, since the loop would execute too many times when I was using the async version of query. In addition to this I had been using ThreadPool.QueueUserWorkItem to execute the search, but had moved it to its own dedicated thread for testing purposes.

`
void GetMessage(object prefix)
{
var filter = new QueryFilter(MESSAGE_PREFIX_KEY, QueryOperator.Equal, prefix.ToString());
_teamMessageData.Clear();

    Search search = null;
    try
    {
        search = _teamMessages.Query(filter);
    }
    catch(Exception ex)
    {
        Debug.LogException(ex);
    }

    if(search == null)
    {
        Debug.Log("returnning null");
        return;
    }

    Debug.Log("SearchCount: " + search.Count);
    while(_teamMessageData.Count != search.Count)
    {
        if(search.Count < 1)
            break;

        _teamMessageData.AddRange(search.GetNextSet());
    }

    _processTeamMessages = true;
    search.Reset();

}
`

Amazon.CognitoIdentity error: java.io.FileNotFoundException: https://cognito-identity.eu-west-1.amazonaws.com/

I'm using the Amazon Mobile SDK for Unity, and have an access token from Google Play (retrieved as described in https://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/cognito-auth.html#use-google), but when I run

credentials.IdentityProvider.Logins.Add ("accounts.google.com", accessToken);
credentials.IdentityProvider.RefreshAsync (RefreshCallback, null);
initializationPending = false;

I get this error, https://gist.github.com/seaders/2de51c11252018361513

And I think the main issue is at,

Amazon.CognitoIdentity error: java.io.FileNotFoundException: https://cognito-identity.eu-west-1.amazonaws.com/
com.sixminute.freeracing E/Unity﹕ curl -X POST  -H "X-Amz-Target: AWSCognitoIdentityService.GetId"  -H "Content-Type: application/x-amz-json-1.1"  -H "User-Agent: AWS-SDK-UNITY/1.0.0"  -H "X-HTTP-Method-Override: POST"  -H "Accept: application/json"  -d '{"AccountId":"36xxxxxxxxxxx91","IdentityPoolId":"eu-west-1:f99xxxxxxxxxxxxxxxxxx926","Logins":{"accounts.google.com":"xxxxxxxxx.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwic3ViIjxxxxxxxxxQyMjI3Njc5OX0.tBXSEOBwgfDa-xxxxxxxxx-pjW1MbtaowiEzIMAtbV95OC7uZrkABU2UeGg"}}'
com.sixminute.freeracing I/Unity﹕ CachingCognitoAWSCredentials: No valid credentials found in LocalStorage

and

Amazon.CognitoIdentity error: java.io.FileNotFoundException: https://cognito-identity.eu-west-1.amazonaws.com/
com.sixminute.freeracing E/Unity﹕ curl -X POST  -H "X-Amz-Target: AWSCognitoIdentityService.GetId"  -H "Content-Type: application/x-amz-json-1.1"  -H "User-Agent: AWS-SDK-UNITY/1.0.0"  -H "X-HTTP-Method-Override: POST"  -H "Accept: application/json"  -d '{"AccountId":"36xxxxxxxxxxx91","IdentityPoolId":"eu-west-1:f99xxxxxxxxxxxxxxxxxx926","Logins":{"accounts.google.com":"xxxxxxxxx.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwic3ViIjoiMTA3OTkzMzI4MTQxNDc1ODE2MzM5IiwiYXpwIjoiNDAxODIxODQ1MDE3LWtmbjM0cWJmMWliMzNzYnNpZxxxxxxxxxOjE0MjIyNzI4OTksImV4cCI6MTQyMjI3Njc5OX0.tBXSEOBwgfDa-xxxxxxxxx-pjW1MbtaowiEzIMAtbV95OC7uZrkABU2UeGg"}}'
com.sixminute.freeracing E/Unity﹕ Cognito error: Error occured during GetCredentialsAsync

However, if I go and take that same access token, and pass it through on the Native app I've got up and running... We authenticate without any problem. Also, if we log in using a Facebook access token, again, everything works without a problem. The only issue I have is when we try to authenticate with a google access token, using the Unity SDK.

Cleaning up where files land from unitypackages

We've a number of plugins and it's been a bit hectic to know exactly what plugin every file belongs to, and also keep sanity to the files structure. The specific egregious ones currently are those that go in to the Assets/ root, License.txt, Notice.txt and link.xml. Each one of these files are named incredibly generically, and if another plugin comes along with License.txt, Notice.txt and link.xml, if any of those files are needed for this SDK to operate (functionally, or legally), they would be instantly overwritten.

With the license and notice, I know I can safely move them in to Assets/AWSUnitySDK/ (which imo is where they should live anyway, and still every other time I install a unitypackage, they come back). But with link.xml I don't actually know. I don't have a full understanding of exactly what this file does, nor where is it safe to be moved to.

I'm reaching out to every plugin creator, and Unity themselves to try get a more mature setup to where unitypackages place files, and thinking about a Upgrade system for them. If you place in version 1.0.1, a necessary file in Assets/, but it's no longer needed in 1.0.2, I have to remember that that file used belong to 1.0.1, but can be safely deleted, but more than likely that's not going to happen, and that redundant file will just be left over. Same for if I want to uninstall the plugin. If everything's within a properly named sub-folder (your AWSUnitySDK folder is a perfect example of this), all of this is sorted out, and is a better setup for all.

Amazon.Unity folder name can cause problems

In the AWSCore, CognitoSync and DynamoDB folders there is a subfolder named Amazon.Unity. Since scene files also have a .unity extension.

This will throw errors on loading the editor (at least on Mac using 4.6.1p4)

error:
Failed to save scene Assets/Asset Store/AWSUnitySDK/CognitoSync/Amazon.Unity.

The solution is to just change the name of the folder to something else that doesn't end in .unity

Standalone PC/Mac Cognito Sync is not working when there is no internet

When I remove all internet connections in Unity Editor PC/Mac standalone, I'm receiving errors when trying to log unauthenticated without using any FB. (Note : I previously logged with FB in the past with this user).

Amazon.CognitoSync.SyncManager.Exceptions.DataStorageException: Failed to list dataset metadata ---> Amazon.Runtime.AmazonServiceException: Could not resolve host: cognito-sync.us-east-1.amazonaws.com; No data record of requested type ---> System.Net.WebException: Could not resolve host: cognito-sync.us-east-1.amazonaws.com; No data record of requested type

Repro

On the cognito sync example, I modified slightly the demo in order to bypass Facebook in case of deconnection.

public class LoginController : MonoBehaviour {

private bool loggingIn = true;

public bool IsInternetAvailable
{
    get
    {
        if (Application.internetReachability == NetworkReachability.NotReachable)
        {
            return false;
        }

        if (Application.isMobilePlatform == false) 
        {
            var ipAddress = Network.player.ipAddress.ToString();
            if (ipAddress == "0.0.0.0") return false;
            if (ipAddress == "127.0.0.1") return false;
        }

        return true;
    }
}

private void Start () 
{
    if (IsInternetAvailable == true)
    {
        FB.Init(InitCallback);
    }
    else
    {
        loggingIn = false;
    }
}

I received this error :

WebException: Could not resolve host: cognito-sync.us-east-1.amazonaws.com; No data record of requested type
Rethrow as AmazonServiceException: Could not resolve host: cognito-sync.us-east-1.amazonaws.com; No data record of requested type

Since on mobile devices disconnected mode is working, Is it something that is supported on other platforms?

This is very convenient and faster to test SyncConflict on a computer without having to go on the mobile device itself.

Thanks

Use of unsupported Linq operations on Unity AOT (iOS) platforms

Certain Linq operations, like OrderBy, require JIT compilation to run. Unity3D AOT platforms like iOS do not support JIT and these operations fail at runtime with the error such as

ExecutionEngineException: Attempting to JIT compile method 'System.Linq.OrderedEnumerable`1<System.Collections.Generic.KeyValuePair`2<string, string>>:GetEnumerator ()' while running with --aot-only.

An example of such use is in Amazon.Runtime.Internal.Auth.AWS4Signer.CanonicalizeHeaders and other related methods.

Possible solutions would be to either reduce reliance on unsupported operations or use AOT-supported Linq implementations like UniLinq

Force close crash when debugging (example is with Cognito, but it's pretty consistent throughout)

When I install aws-unity-sdk-1.0.1-CognitoSync.unitypackage (http://aws.amazon.com/mobile/sdk/ - https://s3.amazonaws.com/aws-unity-sdk/latest/aws-unity-sdk-1.0.1.zip) from the latest update, if I connect the debugger, step through a few things (or not), and then let it continue, or disconnect, or step over the creation of a CognitoAWSCredentials, Unity crashes and hangs, until I eventually have to force close it.

Example of this here, https://www.youtube.com/watch?v=buAANrsEe7c and the exact project is on our github, here https://github.com/SixMinute/CognitoCrashes, nothing else installed except the unitypackage.

This particular example is with Cognito, but we're using all of Cognito, S3 and DynamoDB in our game, and this is severely affecting us developing our game, as we encounter many of these types of hangs since we brought in this package's code.

Feature Request: Simple leaderboard?

So we're using Cognito as the backend to a player's profile in our game, S3 for storing "ghost" data for levels in our game, I'm sure we'll find a use for DynamoDB somewhere in the mix as well, but I was just wondering if a leaderboard is in your plans as well?

I know there's the https://developer.amazon.com/public/apis/engage/gamecircle stuff, but that seems quite out of date / not maintained and slightly a different project to what you guys are doing, not based off of Cognito identity providers, and all that, so we're reticent to try and shoehorn that in... slightly.

Our game is a racing game and currently we're using our own leaderboard backed by Redis on an EC2 instance to store a person's time on a particular track, then some metadata (cognito userId and timestamp), which we then use to figure out the S3 filename, and pull it down from there, and store locally. What'd be awesome is if we could ditch that last service that we require to build and maintain ourselves, and use the leaderboard system you have already.

Lambda Support

It would be great to have Lambda support in the Unity SDK. In particular, I'd like to use Lambda's "request-response" model along with a Cognito identity.

Checking if an identity token is expired

I was wondering if there was a way to check if a cognito identity token had expired. We are currently using Cognito to authenticate our users, however, after about 5 minutes of inactivity the user can no longer access AWS services because the token has expired. This issue appears most often when the user tries to use Cognito Sync to access their dataSet after the app returns from being inactive for a bit. We have rigged up a method for refreshing the credentials after approximately 5 minutes, but this is not guaranteed to sync up with the tokens expiry time. I was hoping you might be able to tell me if there was a more accurate way to tell if the token has expired so that we can make sure the user has the proper authentication.

Web player not working

Our title needs to run on both the Web player and iOs versions. We are receiving crossdomain policy errors when we try to launch from the web version.

This is caused because Unity require that the server validate the connection using the unity call :
"Security.PrefetchSocketPolicy(dstAddressString, port);"

Errors

"curl -X POST -H "X-Amz-Target: AWSCognitoIdentityService.GetId" -H "Content-Type: application/x-amz-json-1.1" -H "X-HTTP-Method-Override: POST" -H "Accept: application/json" -d '{"AccountId":"382057988700","IdentityPoolId":"us-east-1:8100f62b-a81c-4ad2-8ef1-ebaa24f09344"}' https://cognito-identity.us-east-1.amazonaws.com/"

"WebException: Rejected because no crossdomain.xml policy file was found"

Is there any possible workaround around?

Note : To reproduce this issue, simply take the cognito sync sample and switch to "File -> Build Setting -> Switch Platform : select Web player".

Unauthenticated login issues after an hour with Cognito

First let me say that I really enjoy the SDK so far. I will definitively use it.

When I play in Unity Editor PC Standalone, I noticed that If I log using FB authentication first and than at my next connection I started unauthenticated, everything works fine.

But if I wait for more than an hour I will receive errors from the SDK and it will be impossible to get a working unauthenticated session anymore.

After that, if I log back using Facebook it will just work fine for an other hour when logged unauthenticated.

Is this normal behavior?

Support for SQS in Unity SDK

We'd really like to have the Unity SDK support AWS SQS service to help our next mobile game kick ass. Do you have any plans?

Unhandled dataset conflicts

It seems there's a way to botch the local database such that it will fail to sync and fail to notify of any failure.

Looking in DefaultDataset around line 463, I see the following:
AmazonLogging.LogError("CognitoSyncManager", "Conflicts detected when pushing changes to remote: " + putRecordsResult.Exception.Message);

This is getting called several times as it does the retry, but when retry drops below zero, no event is fired. Presumably, at the least, it should fire a SyncFailure:
if (--retry<=0){
FireSyncFailureEvent(putRecordsResult.Exception);
}

However, it would be better if it could fire a conflict event so we could manage the conflict rather than being stuck with a dataset which won't sync.

Thanks

Sync success accept function

I'm trying to write code to handle more complex conflict resolution on the client. Currently you have callback methods for sync conflict, dataset deletion, and dataset merging. All of these can interrupt the process by returning a false and are called prior to the data being committed.

I was wondering if it would be possible to add the same for a sync success. The way a success is currently set up, we get a list of which records are added + updated, but by the time we get that, the records have already been written to the database. We don't have an easy way to determine what changed or which ones are being added. If we could assign a callback, we could run custom logic and then determine whether each record should be committed or not.

As a side note, it might also be nice to separate AddedRecords from UpdatedRecords, again to simplify processing of new data.

How to use from UnityEditor script?

Hi, thanks nice the sdk.
I have tried a sample project, it looks nice. There seems to be created instance of AWSPrefab(AmazonInitializer). But, I'd like to connect to S3 server from UnityEditor script. Not in game, for example:

[MenuItem("AWS/ListObjects")]
public static void AWSListObjects() {
    // It's a just sample. It's called when menu selected.
    var client = new AmazonS3Client();
    client.ListObjectsAsync();
}

I got the error:

Exception: AWSPrefab is not added to the scene
Amazon.S3.AmazonS3Client.ListObjectsAsync (Amazon.S3.Model.ListObjectsRequest request, Amazon.Runtime.AmazonServiceCallback callback, System.Object state) (at Assets/SDK/AWSUnitySDK/S3/Amazon.S3/AmazonS3Client.cs:252)

How to use or do you have any plan?
Thank you.

Is DynamoDB atomic incrementing implemented?

I was attempting to use the .NET guide for how to do an atomic increment, but I noticed that the Unity SDK does not quite follow the same implementation. For example, in the Unity SDK UpdateItemRequest class there is no UpdateExpression property. AmazonDynamoDBClient.sync.UpdateItem mentions an UpdateExpression parameter, but I'm not quite sure how to take advantage of that since I'm attempting to use AmazonDynamoDBClient.UpdateItemAsync() to update my item atomically. What is the correct way to do an atomic increment with the Unity SDK?

Changing IDs back and forth advice or "AmazonClientException: UNIQUE constraint failed: datasets.identity_id, datasets.dataset_name"

So I'm overall asking about the strategy for when someone who had previously logged in to Facebook let their accessToken expire, and didn't bother logging in again.

I've currently gone with the strategy of recording to Unity's PlayerPrefs whether someone was authenticated with a social platform access token the last time they ran the app, and if they were logged in, but now aren't, I run credentials.ClearCredentialsAndIdentity(). This has to be done because it seems a credentials refresh doesn't work properly if you run it again without valid access tokens.

Now, this happens ok for if someone was logged in, but now isn't, they swap from one ID to another, but if they then go to log in again afterwards, this is where the crash happens. In SQLiteLocalStorage.cs - ChangeIdentityId, it tries to run an update statement on the database, but it's trying to update the unauthenticated identity_id to the authenticated one from earlier. Unfortunately, that is still in the database, so I get that exception, UNIQUE constraint failed: datasets.identity_id, datasets.dataset_name.

What should be done in this regard, removing the conflict at that point, ignoring it, or removing the entry when credentials.ClearCredentialsAndIdentity() was called?

version 1.04 compile errors on iOS with Unity 5.0.1p4

In AmazonHookedPlatformInfo:

starting at line 275:

        if(iPhone.generation.ToString().StartsWith("iPhone"))
        {
            Model = "iPhone";
        }
        else if (iPhone.generation.ToString().StartsWith("iPad"))
        {
            Model = "iPad";
        }
        else
        {
            Model = "iPod";
        }

generates this error at build time:

Assets/Asset Store/AWSUnitySDK_1.04/AWSCore/Amazon.Unity3D/AmazonHookedPlatformInfo.cs(275,16): error CS0103: The name `iPhone' does not exist in the current context

It is now Device.generation (in UnityEngine.iOS).

Putting that in seems to fix the problem.

Webgl support

1.05 doesn't run in the webgl player currently.

If you replace every instance of UNITY_WEBPLAYER with (UNITY_WEBPLAYER || UNITY_WEBGL) it will at least load without complaining about sqlite3 dlls.

Currently with this setup it works in the Unity IDE but does not work in an actual WebGL build (I tested the S3 example using Firefox and Chrome).

It appears the issue may be with attempting to use _pthread_create.

edit: The main reason for supporting this is that Chrome is/has dropped support for plugins - see https://www.chromium.org/developers/npapi-deprecation

RefreshAsync failed on iOS with latest SDK and Unity 5

RefreshAsync failed
Amazon.CognitoIdentity.<GenerateNewCredentialsAsync>c__AnonStorey44:<>m__18(AmazonServiceResult) (at /Developer/repos/git/freeracing/Assets/AWSUnitySDK/AWSCore/Amazon.CognitoIdentity/CognitoAWSCredentials.cs:294)
Amazon.Unity3D.<FireCallbackOnCoRoutine>c__Iterator2:MoveNext() (at /Developer/repos/git/freeracing/Assets/AWSUnitySDK/AWSCore/Amazon.Unity3D/AmazonMainThreadDispatcher.cs:94)

The curl command that it spits out is,

curl -X POST  -H "X-Amz-Target: AWSCognitoIdentityService.GetId"  -H "Content-Type: application/x-amz-json-1.1"  -H "User-Agent: AWS-SDK-UNITY/1.0.4"  -H "X-HTTP-Method-Override: POST"  -H "Accept: application/json"  -d '{"IdentityPoolId":"us-east-1:cc43fef0-cb92-43ee-8156-71e3885f8d44"}'  https://cognito-identity.us-east-1.amazonaws.com/

And delving a little more / spitting out a bit more information about the error,

{"ClassName":"Amazon.Runtime.AmazonServiceException","Message":"The operation couldn’t be completed. (NSURLErrorDomain error -1012.)","InnerException":{"ClassName":"System.Net.WebException","Message":"The operation couldn’t be completed. (NSURLErrorDomain error -1012.)","InnerException":null,"HelpURL":null,"StackTraceString":null,"RemoteStackTraceString":null,"RemoteStackIndex":0,"HResult":-2146233079,"Source":null,"ExceptionMethod":null,"Data":null},"HelpURL":null,"StackTraceString":null,"RemoteStackTraceString":null,"RemoteStackIndex":0,"HResult":-2146233088,"Source":null,"ExceptionMethod":null,"Data":null}
Amazon.CognitoIdentity.<GenerateNewCredentialsAsync>c__AnonStorey44:<>m__18(AmazonServiceResult) (at /Developer/repos/git/freeracing/Assets/AWSUnitySDK/AWSCore/Amazon.CognitoIdentity/CognitoAWSCredentials.cs:292)

Replicating the call via

        WWWForm form = new WWWForm();
        form.AddField( "IdentityPoolId", "us-east-1:cc43fef0-cb92-43ee-8156-71e3885f8d44" );

        Dictionary<string, string> headers = form.headers;
        var encoding = new System.Text.UTF8Encoding();

        Dictionary<string, string> dict = new Dictionary<string, string>();
        dict["IdentityPoolId"] = "us-east-1:cc43fef0-cb92-43ee-8156-71e3885f8d44";
        byte[] rawData = encoding.GetBytes( SMUtils.SerializeToString(dict) );
        string url = "https://cognito-identity.us-east-1.amazonaws.com/";

        // Add a custom header to the request.
        // In this case a basic authentication to access a password protected resource.
        headers["X-Amz-Target"] = "AWSCognitoIdentityService.GetId";
        headers["Content-Type"] = "application/x-amz-json-1.1" ;
        headers["User-Agent"] = "AWS-SDK-UNITY/1.0.4";
        headers["X-HTTP-Method-Override"] = "POST";
        headers["Accept"] = "application/json";

        // Post a request to an URL with our custom headers

        WWW www = new WWW(url, rawData, headers);
        yield return www;

        Debug.Log( string.Join( "\n", www.responseHeaders.Select(x => "[" + x.Key + ": " + x.Value + "]").ToArray() ) + "\n\n" + www.data );

works fine in the emulator (and on Android), but not on the iPad we're testing with, despite other POST, and GET www calls working fine.

What's up here? I also have to ask what is your testing platform like, because (like Unity themselves) it seems like both OSX and iOS testing is sparsely done, at best.

Cognito Sync 403 Error

We are developing a mobile game using Unity and we are going to use AWS services to store all the user data and the game content.

We already built all the integration and archived to integrate with the AWS SDK for unity, the DynamoDB and S3 are working as expected but we are have some trouble with CognitoStore.

When we call _ds.Synchronize () or _syncManager.RefreshDatasetMetadataAsync() we get the a 403 Forbidden Error.

"WebException: 403 Forbidden
Rethrow as AmazonServiceException: 403 Forbidden
Rethrow as DataStorageException: Failed to list records in dataset: Account"

Our policy (simplified):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:"
],
"Resource": [
"
"
]
}
]
}

The code calling the service is simple:
try {
CognitoSyncClientManager.init();
_syncManager = CognitoSyncClientManager.CognitoSyncManagerInstance;
} catch (Exception ex) {
Debug.LogException (ex);
return;
}

_dsAccount = _syncManager.OpenOrCreateDataset ("Account");
_dsAccount.Put ("test", "1");
_dsAccount.Synchronize ();

Note: We are having the same issue with the Sample project.

More details in the AWS Forum: https://forums.aws.amazon.com/message.jspa?messageID=601541#601541

QueryRequest.QueryFilter not working?

I attempted to use
queryRequest.QueryFilter.Add("IsActive", new Condition { AttributeValueList = { new AttributeValue { N = "1" } }, ComparisonOperator = ComparisonOperator.EQ });
but get a 400 Bad Request Response back. I'm using this on a global secondary index query with TableName, IndexName and KeyCondition specified. "IsActive" is a projected attribute on my GSI. I'm using the QueryRequest with AmazonDynamoDBClient.QueryAsync(). It works when I comment out my QueryFilter line.

SynchronizeOnConnectivity()

The implementation of this method is simply:

throw new NotImplementedException();

:-(

Is this on the roadmap to actually implement?

Thanks!

AWSPrefab/AmazonInitializer

There seem to be places in the code which require the AmazonInitializer. I see that Credentials doesn't require the script, which is great, but I'm finding SQLiteKVStore.cs is trying to pull the AmazonInitializer.persistentDataPath even if I have generated Credentials without using the AmazonInitializer.

It'd be great if we could handle all data during setup through constructor args rather than requiring the script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.