0

I am trying to access the user name and user Image url after login using AWS SDK iOS but i am getting following error :

Value of type 'AWSIdentityManager' has no member 'identityProfile' Although the same code was working fine in previous SDK(2.5.10), please help me in getting the user details after login.

My current SDK version is 2.6.1

Here is my code :-

     if let identityUserName = identityManager.identityProfile?.userName {
          print("User ID\( identityManager.identityId!)")
           print("User name\(identityUserName)")
        }


        if let imageURL = identityManager.identityProfile?.imageURL {
         print(imageURL)               
        }

I have managed to access the user Name by using following code if i login with custom login , but if i try to login with Facebook or Gmail i get nil in response.

Code :-

let currUserPool = AWSCognitoIdentityUserPool.default()

let currUser = currUserPool.currentUser()

let username = currUser?.username
user4261201
  • 2,324
  • 19
  • 26
Aseem
  • 423
  • 5
  • 7

1 Answers1

1

The Sample Application downloaded from AWS Mobile Hub had the IdentityProfile which helps you retrieve the username and imageURL. On 08/31, the IdentityProfile was removed from the Sample Application and the AWSIdentityManager was moved to an SDK library available as pod 'AWSAuthCore', '~> 2.6' if you are using cocoapods.

For UserPools:

For retrieving the username from UserPoolsSignIn, you can do the following:

Add this import:

import AWSUserPoolsSignIn

AWSCognitoUserPoolsSignInProvider.sharedInstance().getUserPool().currentUser()?.username

For Facebook:

How to get user name and email id for Facebook SDK?

For Google:

https://developers.google.com/identity/sign-in/ios/people

Karthikeyan
  • 1,411
  • 1
  • 13
  • 13