我想將AWS Cognito集成到我的移動應用程序中並主要使用Facebook和Google登錄,並且一旦用戶登錄,他就可以從S3上載/下載文件並與其交互DynamoDB也是如此。我還希望特定用戶的cognitoID成爲DynamoDB中識別每個用戶的主鍵。 首先,這是一個好主意,保持用戶識別每個用戶的認證ID(IdentityID)?使用Cognito通過Facebook登錄後無法獲取身份ID
其次,當我嘗試使用getIdentityID從sharedInstance拿到身份ID,在以下
// Retrieve your Amazon Cognito ID
credentialsProvider.getIdentityId().continueWithBlock { (task: AWSTask!) -> AnyObject! in
if (task.error != nil) {
print("Error: " + task.error.localizedDescription)
}
else {
// the task result will contain the identity id
let cognitoId = task.result
}
return nil
}
的行或多或少我沒有得到所需要的IdentityID,而是我得到一個零和因此不能堅持。 我錯過了什麼嗎? 如果您需要更多信息,請讓我知道。
我使用ClientManager作爲 [鏈接](HTTPS給出://github.com/awslabs/aws-sdk-ios-samples/blob/master/CognitoSync-Sample/Swift/CognitoSyncDemo/AmazonClientManager.swift) 在我的項目中,這裏上面的代碼在功能 initializeClients 。 並在一些其他viewController訪問身份ID我嘗試了兩個 AmazonClientManager.sharedInstance.credentialsProvider?.identityId和我的問題給出的,都給我零。 –
嘗試一些基本的東西。如上所述初始化客戶端,在該客戶端上調用刷新,等待幾秒鐘,然後檢查它。那麼它是否設置? –