我是iOS应用中的AWS Cognito和AWSCognitoDataset。
我正在调用registerCognitoWithConfiguration()但这已被弃用。 而应该使用init()。但我认为我需要使用的那个需要一个我无法访问的identityId,直到我使用credentialsProvider来调用getIdentityId() - 这是一个catch 22。
那么,我该如何替换registerCognitoWithConfiguration()?
Digits.sharedInstance().authenticateWithViewController( ...
{session, error in
if session != nil {
self.completeDigitsLogin()
} else {
...
}
func completeDigitsLogin() {
if let session = Digits.sharedInstance().session() {
AWSCognitoCredentialsProvider.credentialsWithRegionType(
Constants.COGNITO_REGIONTYPE,
accountId:Constants.AWS_ACCOUNT_ID,
identityPoolId:Constants.COGNITO_IDENTITY_POOL_ID,
unauthRoleArn:"",
authRoleArn:Constants.COGNITO_ARN_AUTH_ROLE,
logins:["www.digits.com": makeTwitterSessionString(session)])
let conf = AWSServiceConfiguration(
region:Constants.COGNITO_REGIONTYPE,
credentialsProvider:credentialsProvider)
AWSCognito.registerCognitoWithConfiguration(config, forKey:"main")
credentialsProvider.getIdentityId().continueWithBlock {
(task:AWSTask!) -> AnyObject! in
let cognitoId = task.result as! String
print("CognitoId = \(cognitoId)")
let cognitoSync = AWSCognito(forKey:"main")
self.dataset = cognitoSync.openOrCreateDataset("Candidate")
self.dataset.setString(session.phoneNumber, forKey:"phone")
self.synchronizeDataset()
return nil
}
}
}
答案 0 :(得分:0)
似乎不推荐使用registerCognitoWithConfiguration()。
https://github.com/aws/amazon-cognito-ios/blob/master/Cognito/AWSCognitoService.m#L118
https://github.com/aws/amazon-cognito-ios/blob/master/Cognito/AWSCognitoService.h#L232