Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
谷歌登录swift_Swift_Google Signin - Fatal编程技术网

谷歌登录swift

谷歌登录swift,swift,google-signin,Swift,Google Signin,我想登录谷歌,但我不能得到用户的姓氏 如何获取用户的名字、姓氏 我使用以下代码: withError error: NSError!) { if (error == nil) { // Perform any operations on signed in user here. let userId = user.userID // For client-side use only!

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

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

我使用以下代码:

    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]
        }

名称字段包含名字和姓氏

示例名称=阿伦·史密斯

然后名字=阿伦,姓氏=史密斯

否则,无法在IOS中使用谷歌登录获取姓名