我很高兴地使用Cognito Sync和我的预发布应用程序(iOS/Objective-C),并使用Facebook登录。但是,在提交Apple App Store评论时,我被要求删除Facebook登录。我认为这将很简单 - 只需将非真实角色策略更改为与auth用户匹配,并绕过任何与Facebook身份验证相关的操作。AWS Cognito身份更改为匿名/访客用户
但是,现在我发现identityId在会话之间发生变化。它表现得像会话ID。这是一个令人头痛的问题,因为我的应用程序在DynamoDB中使用identityId作为散列键。因此,例如,DynamoDB搜索当前用户最近的活动仅显示当前会话的历史记录,而不是所有预期的历史记录。
我正在使用示例应用程序的代码来获取identityId - 它似乎得到正确分配。根据样本的AWSIdentityManager.m,下面是里面didFinishLaunchingWithOptions
的AppDelegate.m的一部分:
AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AMAZON_COGNITO_REGION
identityPoolId:AMAZON_COGNITO_IDENTITY_POOL_ID];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AMAZON_COGNITO_REGION
credentialsProvider:credentialsProvider];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
[[credentialsProvider getIdentityId] continueWithBlock:^id(AWSTask *task) {
if (task.error) {
NSLog(@"Error: Could not obtain identity id: %@", task.error);
}
else {
// the task result will contain the identity id
NSString *cognitoId = task.result;
NSLog(@"Got the identity ID as %@", cognitoId);
// Don't change the ID
NSString *oldId = [[NSUserDefaults standardUserDefaults] objectForKey:NSUD_COGNITO_ID];
if (!oldId) {
[[NSUserDefaults standardUserDefaults] setObject:cognitoId forKey:NSUD_COGNITO_ID];
[[NSUserDefaults standardUserDefaults] synchronize];
} else {
NSLog(@"Old = %@, New = %@, Keeping old", oldId, cognitoId);
}
}
return nil;
}];
我一直得到新老身份是不一样的消息。另外,当我检入Cognito Sync时,将无法再找到旧身份。
既然没有使用Facebook SignIn提供程序,我如何确保IdentityId不会跨会话等发生变化?有人可以阐明为什么这会改变吗?我已经确认我没有清除代码中任何地方的钥匙串。
如果有帮助:前几个条目具有“us-east-1:c5263844-7229-4e48-a203-f4c547871339”作为identityId,并且随后的条目具有“us-east-1:86a69d0f-bb28-4acd- a229-9821d18e56ba“作为身份标识。我检查了Cognito身份浏览器,并且第一个值不存在。 – LNI
我刚刚升级到2.3.3,并在日志中看到一条新消息:“[AWSCognitoDataset synchronizeInternal:] |冲突重试耗尽”。这是否指向潜在的原因? – LNI