我想登录到谷歌,但我不能获得用户的姓氏...
如何获取用户的名字、姓氏?
我使用以下代码:
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]
}发布于 2015-11-26 14:52:22
name字段包含名字和姓氏
示例"name“= Alen Smith
然后名字= Alen,姓氏= Smith
否则就无法在IOS中使用谷歌登录来获取名字和姓氏。
https://stackoverflow.com/questions/33927438
复制相似问题