iOS-使用Google SignIn SDK获取名字和姓氏

iOS-使用Google SignIn SDK获取名字和姓氏,ios,objective-c,google-plus,Ios,Objective C,Google Plus,我正在使用谷歌登录SDK,它工作得非常好。我能够获得以下数据: NSString *userId = user.userID; // For client-side use only! NSString *idToken = user.authentication.idToken; // Safe to send to the server NSString *name = user.profile.name; NSString *email = user.pr

我正在使用谷歌登录SDK,它工作得非常好。我能够获得以下数据:

NSString *userId = user.userID;                  // For client-side use only!
NSString *idToken = user.authentication.idToken; // Safe to send to the server
NSString *name = user.profile.name;
NSString *email = user.profile.email;

我如何检索名字和姓氏?和其他信息,例如用户居住的城市,等等?

您在
user.profile.name
中已经有了名字和姓氏,这是全名

有关其他信息,您可以调用web API:

GET https://www.googleapis.com/plus/v1/people/me?fields=aboutMe%2Cbirthday%2CcurrentLocation%2CplacesLived&key={YOUR_API_KEY}
您可以通过添加更多参数来获取其他信息。更多细节,谷歌在这里解释

https://developers.google.com/+/web/api/rest/latest/people/get#examples

您在
user.profile.name
中已经有了名字和姓氏,这是全名

有关其他信息,您可以调用web API:

GET https://www.googleapis.com/plus/v1/people/me?fields=aboutMe%2Cbirthday%2CcurrentLocation%2CplacesLived&key={YOUR_API_KEY}
您可以通过添加更多参数来获取其他信息。更多细节,谷歌在这里解释

https://developers.google.com/+/web/api/rest/latest/people/get#examples

我也面临着和你一样的问题。您无法从Google SDK中分别获取名字和姓氏。相反,您可以按如下方式手动执行

NSString *name = user.profile.name;
NSArray *items = [name componentsSeparatedByString:@" "];   //take one array for splitting the string
NSString *fname = [items objectAtIndex:0];
NSString *lname = [items objectAtIndex:1];

我也面临着和你一样的问题。您无法从Google SDK中分别获取名字和姓氏。相反,您可以按如下方式手动执行

NSString *name = user.profile.name;
NSArray *items = [name componentsSeparatedByString:@" "];   //take one array for splitting the string
NSString *fname = [items objectAtIndex:0];
NSString *lname = [items objectAtIndex:1];

我想使用Google iOS SDK实现这一点。另外,我希望名字和姓氏分开…全名没有帮助。我想用谷歌iOS SDK实现这一点。另外,我想要名字和姓氏分开…全名没有帮助。