AWS Cognito Swift credentials provider “logins is deprecated: Use AWSIdentityProviderManager”

前端 未结 1 456
慢半拍i
慢半拍i 2020-12-03 19:54

Im trying to allow users to sign up with my app using facebook and Amazon Cognito. I found previous documentation saying to use:

    let token = FBSDKAccessT         


        
相关标签:
1条回答
  • 2020-12-03 20:33

    After looking around I finally found out I wasn't the only one with this issue. AWS updated their sdk without changing their main documentation. The solution is to implement the AWSCognitoIdentityProviderManager in a custom class and feed that to the credentials provider. Heres the code provided by simaomi in the github discussion below (its more of a quick fix):

    import Foundation
    import AWSCore
    import AWSCognito
    import AWSCognitoIdentityProvider
    class CustomIdentityProvider: NSObject, AWSCognitoIdentityProviderManager{
        var tokens : [NSString : NSString]?
        init(tokens: [NSString : NSString]) {
            self.tokens = tokens
        }
        @objc func logins() -> AWSTask {
            return AWSTask(result: tokens)
        }
    }
    
    
    let customProviderManager = CustomIdentityProvider(tokens: logins!)
    
    self.credentialsProvider = AWSCognitoCredentialsProvider(
       regionType: Constants.COGNITO_REGIONTYPE,
       identityPoolId: Constants.COGNITO_IDENTITY_POOL_ID,
       identityProviderManager: customProviderManager)
    

    the sdk example shows how you should really implement the solution

    Look here for the discussion: https://github.com/aws/aws-sdk-ios/issues/357

    and here for updated sdk examples: https://github.com/awslabs/aws-sdk-ios-samples/tree/developer-authenticated-identities-2-4/CognitoSync-Sample

    0 讨论(0)
提交回复
热议问题