2
- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user
     withError:(NSError *)error {
    NSString *userId = user.userID;
    NSString *idToken = user.authentication.idToken;
    NSString *name = user.profile.name;
    NSString *email = user.profile.email;
    //NSString *Url = user.profile.imageURL;
}

I tried to get google login user details. How to get profileImageUrl? any help will be apricated.thanks in advance

Cong Tran
  • 1,448
  • 14
  • 30
karthi
  • 39
  • 5
  • Possible duplicate of [How to get user image through user id in Google plus?](http://stackoverflow.com/questions/22406756/how-to-get-user-image-through-user-id-in-google-plus) –  Dec 16 '15 at 06:57

1 Answers1

0

Google has defined a method to get Profile image URLs for iOS API. That method is -(NSURL *) imageURLWithDimension:(NSUInteger) dimension. You only need to do the following:

Use this code after signing in:

 if(user.profile.hasImage)
{
    NSURL *imageURL = [user.profile imageURLWithDimension(50)]; //Give your desired dimenion in parameter.
}

This is defined in Google API documentation.

If you get an unexpected FIFEURL error as some users have in the past, See this already answered question to fix it. But that should not occur again because according to Google:

this is fixed in 2.3.1 that we've just released.

See status on that bug here.

And a suggestion, put your login success code inside a if(!error) clause. Right now you are assuming that a failure in login will never occur. (If you have already done that but didn't show it here then ignore this suggestion).

Community
  • 1
  • 1
NSNoob
  • 5,548
  • 6
  • 41
  • 54
  • getting error as " Property 'imageURLWithDimension' not found on object of type 'GIDProfileData *'" – karthi Dec 16 '15 at 05:58
  • @karthi sorry about that typo. I have updated the code. It is a method not a property thats why the error. Should work now! – NSNoob Dec 16 '15 at 06:00