iOS Google登录无法获取用户个人资料图片?(不是Google plus登录)

Vin*_*det 5 objective-c ios google-plus-signin google-signin

我正在尝试在我的应用中进行谷歌登录工作,但有问题.

(不是谷歌加登录,我正在使用谷歌登录)

我按照这个链接,它的工作原理.我得到userID,user.authentication.idToken,user.profile.name和user.profile.email.

但我无法找到如何获取用户个人资料图片的方式.以上谷歌文档没有评论.

我在网上搜索了几个小时,但发现只有谷歌加登录,我不想要.

我在我的应用程序中实现了Facebook登录,并提供了获取用户个人资料图片的网址.

谷歌登录服务是这样的吗?

这是我的工作代码获取用户信息但没有图片.

请帮忙

- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error {

if (user) {
    NSString *userId = user.userID;                  // For client-side use only!
    NSString *token = user.authentication.idToken;   // Safe to send to the server
    NSString *name = user.profile.name;
    NSString *email = user.profile.email;
...
}
Run Code Online (Sandbox Code Playgroud)

小智 26

你必须设置[GIDSignIn sharedInstance] .shouldFetchBasicProfile = YES; 并使用下面的代码获取配置文件pic

    if ([GIDSignIn sharedInstance].currentUser.profile.hasImage)
    {
        NSUInteger dimension = round(thumbSize.width * [[UIScreen mainScreen] scale]);
        NSURL *imageURL = [user.profile imageURLWithDimension:dimension];
    }
Run Code Online (Sandbox Code Playgroud)

快速实施:

let dimension = round(thumbSize.width * UIScreen.mainScreen().scale);
let pic = user.profile.imageURLWithDimension(dimension) 
Run Code Online (Sandbox Code Playgroud)

  • 上面的回答是什么? (2认同)