适用于iOS应用的AWS

时间:2017-02-03 10:43:11

标签: ios xcode amazon-web-services amazon-s3

我已经在我的AWS游戏中设置了Unity,它在编辑器和Android上运行良好但是当我在iOS上测试时它似乎无法访问AWS正常。

我已将NSAppTransportSecurity元素添加到我的info.plist文件中,但这似乎没有帮助。

如果有帮助,我使用的服务是Cognito and SimpleDB

这是我在尝试访问AWS时从Xcode调试器获得的错误:

  

NullReferenceException:在对象中找到空值   实例是必需的。在Amazon.AWSConfigs.get_LoggingConfig()   [0x00000] in:0 at   Amazon.Runtime.ClientConfig..ctor()[0x00000] in:0   在Amazon.CognitoIdentity.AmazonCognitoIdentityConfig..ctor()   [0x00000] in:0 at   Amazon.CognitoIdentity.AmazonCognitoIdentityClient..ctor   (Amazon.Runtime.AWSCredentials凭据,Amazon.RegionEndpoint   region)[0x00000] in:0 at   Amazon.CognitoIdentity.CognitoAWSCredentials..ctor(System.String   accountId,System.String identityPoolId,System.String unAuthRoleArn,   System.String authRoleArn,Amazon.RegionEndpoint region)[0x00000] in   :GameControl.get_Credentials上的0

感谢您的帮助

编辑:

这就是我对Cognito和SimpleDB的引用的设置方式:

    private CognitoAWSCredentials _credentials;

public CognitoAWSCredentials Credentials
{
    get
    {
        if (_credentials == null)
            _credentials = new CognitoAWSCredentials("IDENTITY_POOL_HERE", RegionEndpoint.APSoutheast2);
        return _credentials;
    }
}

private AmazonSimpleDBClient _simpleDB;

public AmazonSimpleDBClient SimpleDB
{
    get
    {
        if (_simpleDB == null)
        {
            //Connect to the DB
                _simpleDB = new AmazonSimpleDBClient(
                    credentials: Credentials, 
                    region: RegionEndpoint.USWest2);
        }
        return _simpleDB;
    }
}

这就是我所说的:

//Disable SSL certification (This prevents "authentication or decryption has failed" error and "Invalid certificate")
    System.Net.ServicePointManager.ServerCertificateValidationCallback +=
       delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
                               System.Security.Cryptography.X509Certificates.X509Chain chain,
                               System.Net.Security.SslPolicyErrors sslPolicyErrors)
       {
           return true; // **** Always accept
       };

    username = PlayerPrefs.GetString("Identity");

    if (username == null || username == "")
    {
        username = Credentials.GetIdentityId();
        PlayerPrefs.SetString("Identity", username);
        PlayerPrefs.Save();
    }

    //Check if this user has any bots yet (if they do that we don't need to do the first time setup)
    string selectExpression = "Select count(*) From Bots where UserName = '" + username + "'";
    var selectRequestAction = new SelectRequest { SelectExpression = selectExpression };
    var selectResponse = SimpleDB.Select(selectRequestAction);

0 个答案:

没有答案