AWS cognito 示例应用程序的问题

Issue with AWS cognito sample app

我正在尝试 运行 来自 https://github.com/awslabs/aws-sdk-ios-samples/tree/master/CognitoSync-Sample/Swift 的这个 AWS Cognito 示例应用程序。我可以添加新的数据集,但是一旦我尝试 sync/refresh 我就会收到以下错误。我没有尝试与任何提供者合作。只是简单的数据同步。

这是我执行的步骤 -

1.Downloaded 来自 github 的示例应用程序。

2.Installed AWSCognito 按给定的方式使用 pod

3.And 在 Amazon cognito 控制台中创建了身份池

4.and 更新了 Constants.swift -

中的常量

static 让 COGNITO_REGIONTYPE = AWSRegionType.USEast1 静态让 COGNITO_IDENTITY_POOL_ID = "us-east-1_XXXXXXXXX"

这是我的控制台的错误 -

2016-05-11 15:43:49.643 CognitoSyncDemo[18352:6625488] AWSiOSSDKv2 [Debug] AWSCognitoSQLiteManager.m line:179 | __51-[AWSCognitoSQLiteManager initializeDatasetTables:]_block_invoke | sqlString = 'INSERT INTO CognitoMetadata(Dataset,ModifiedBy,IdentityId) VALUES (?,?,?)'
2016-05-11 15:43:49.643 CognitoSyncDemo[18352:6625488] AWSiOSSDKv2 [Debug] AWSCognitoSQLiteManager.m line:282 | __53-[AWSCognitoSQLiteManager loadDatasetMetadata:error:]_block_invoke | query = 'SELECT LastSyncCount, LastModified, ModifiedBy, CreationDate, DataStorage, RecordCount FROM CognitoMetadata WHERE IdentityId = ? and Dataset = ?'
2016-05-11 15:43:49.647 CognitoSyncDemo[18352:6625968] AWSiOSSDKv2 [Verbose] AWSURLRequestSerialization.m line:103 | -[AWSJSONRequestSerializer serializeRequest:headers:parameters:] | Request body: [{"IdentityPoolId":"us-east-1_1kBTIfzWu"}]
2016-05-11 15:43:50.942 CognitoSyncDemo[18352:6626097] AWSiOSSDKv2 [Debug] AWSURLResponseSerialization.m line:74 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response header: [{
Connection = close;
"Content-Length" = 218;
"Content-Type" = "application/x-amz-json-1.1";
Date = "Wed, 11 May 2016 10:13:50 GMT";
"x-amzn-ErrorMessage" = "1 validation error detected: Value 'us-east-1_1kBTIfzWu' at 'identityPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+";
"x-amzn-ErrorType" = "ValidationException:";
"x-amzn-RequestId" = "0ec70838-1761-11e6-91c2-e77b976ab658";
}]
2016-05-11 15:43:50.942 CognitoSyncDemo[18352:6626097] AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:79 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: [{"__type":"ValidationException","message":"1 validation error detected: Value 'us-east-1_1kBTIfzWu' at 'identityPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+"}]
2016-05-11 15:43:50.943 CognitoSyncDemo[18352:6626097] AWSiOSSDKv2 [Error] AWSIdentityProvider.m line:185 | __51-[AWSAbstractCognitoIdentityProvider getIdentityId]_block_invoke169 | GetId failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=0 "(null)" UserInfo={__type=ValidationException, message=1 validation error detected: Value 'us-east-1_1kBTIfzWu' at 'identityPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+}]
2016-05-11 15:43:50.943 CognitoSyncDemo[18352:6625968] AWSiOSSDKv2 [Verbose] AWSURLRequestSerialization.m line:103 | -[AWSJSONRequestSerializer serializeRequest:headers:parameters:] | Request body: [{"IdentityPoolId":"us-east-1_1kBTIfzWu"}]
2016-05-11 15:43:52.168 CognitoSyncDemo[18352:6626097] AWSiOSSDKv2 [Debug] AWSURLResponseSerialization.m line:74 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response header: [{
Connection = close;
"Content-Length" = 218;
"Content-Type" = "application/x-amz-json-1.1";
Date = "Wed, 11 May 2016 10:13:51 GMT";
"x-amzn-ErrorMessage" = "1 validation error detected: Value 'us-east-1_1kBTIfzWu' at 'identityPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+";
"x-amzn-ErrorType" = "ValidationException:";
"x-amzn-RequestId" = "0f7792fc-1761-11e6-9ad4-59d8bf47e69e";
}]
2016-05-11 15:43:52.168 CognitoSyncDemo[18352:6626097] AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:79 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: [{"__type":"ValidationException","message":"1 validation error detected: Value 'us-east-1_1kBTIfzWu' at 'identityPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+"}]
2016-05-11 15:43:52.168 CognitoSyncDemo[18352:6626097] AWSiOSSDKv2 [Error] AWSIdentityProvider.m line:185 | __51-[AWSAbstractCognitoIdentityProvider getIdentityId]_block_invoke169 | GetId failed. Error is [Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=0 "(null)" UserInfo={__type=ValidationException, message=1 validation error detected: Value 'us-east-1_1kBTIfzWu' at 'identityPoolId' failed to satisfy constraint: Member must satisfy regular expression pattern: [\w-]+:[0-9a-f-]+}]
2016-05-11 15:43:52.169 CognitoSyncDemo[18352:6626097] AWSiOSSDKv2 [Error] AWSCognitoService.m line:176 | __36-[AWSCognito refreshDatasetMetadata]_block_invoke147 | Unable to list datasets: Error Domain=com.amazon.cognito.AWSCognitoErrorDomain Code=-4000 "(null)"

我错过了什么?我对 AWS 服务还很陌生,非常感谢任何指导。

谢谢, 里查

我使用的是用户池 ID 而不是身份池 ID。现在解决了。

是的,这几乎总是使用用户池 ID 而不是身份池。

请注意,如果您在初始化 AWSCognitoCredentialsProvider() 时输入正确的身份池 ID,它将在模拟器中运行,即使您的 info.plist AWS 字典描述符中的 ID 错误。但在设备上它将使用 info.plist 池 ID,如果错误则失败。这让我很生气,所以请确保您的池 ID 在两个位置都是正确的。