首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google登录swift

Google登录swift
EN

Stack Overflow用户
提问于 2015-11-26 06:20:39
回答 1查看 177关注 0票数 0

我想登录到谷歌,但我不能获得用户的姓氏...

如何获取用户的名字、姓氏?

我使用以下代码:

代码语言:javascript
复制
    withError error: NSError!) {
        if (error == nil) {
            // Perform any operations on signed in user here.
            let userId = user.userID                  // For client-side use only!
            let idToken = user.authentication.idToken // Safe to send to the server
            let name = user.profile.name

            let email = user.profile.email


            // [START_EXCLUDE]
            NSNotificationCenter.defaultCenter().postNotificationName(
                "ToggleAuthUINotification",
                object: nil,
                userInfo: ["statusText": "Signed in user:\n\(name)"])
            // [END_EXCLUDE]
        } else {
            print("\(error.localizedDescription)")
            // [START_EXCLUDE silent]
            NSNotificationCenter.defaultCenter().postNotificationName(
                "ToggleAuthUINotification", object: nil, userInfo: nil)
            // [END_EXCLUDE]
        }
EN

回答 1

Stack Overflow用户

发布于 2015-11-26 14:52:22

name字段包含名字和姓氏

示例"name“= Alen Smith

然后名字= Alen,姓氏= Smith

否则就无法在IOS中使用谷歌登录来获取名字和姓氏。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33927438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档