I’ve been trying to authenticate user with Facebook and Twitter on iOS with Amazon Cognito. I can’t implement because Official documents is old.
Here is my code:
NSString *token = [FBSDKAccessToken currentAccessToken].tokenString;
credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionAPNortheast1 identityPoolId:IDENTITY_POOL_ID];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionAPNortheast1
credentialsProvider:credentialsProvider];
credentialsProvider.logins = @{ AWSIdentityProviderFacebook: token };
NSLog(@"credentialsProvider.logins : %@", credentialsProvider.logins);
[AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration;
But Xcode says that ‘logins’ is deprecated: Use “AWSIdentityProviderManager” to provide a valid logins dictionary to the credentials provider
I figured out that credentialsProvider.logins returns [null] as logins is deprecated.
Amazon official documents (English, Japanese) & samples are not up-to-date so I don’t know how to implement correctly to authenticate user.
Finally, I found a solution for this in Swift but I don’t know.
AWS Cognito Swift credentials provider "logins is deprecated: Use AWSIdentityProviderManager"
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)
Could you convert these codes to Objective-C and tell me how to use converted codes in my above code? Or please tell me the official recommended code?