我已在我的IOS应用程序中集成了google plus,但我无法获取登录的当前用户的电子邮件ID [英] I have integrated google plus in my IOS App ,But I am not able to get email Id of current user that is logged In

查看:114
本文介绍了我已在我的IOS应用程序中集成了google plus,但我无法获取登录的当前用户的电子邮件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的ios应用中集成了google plus,我能够成功登录,但我无法获得登录的当前用户的电子邮件ID。
我已经引用了 https://developers.google.com/+/mobile/ios/ 并按照所有步骤操作这是登录所必需的!

I have integrated google plus in my ios app ,I am able to sign in successfully but I am not able to get email Id of current user that is logged in. I have referd to https://developers.google.com/+/mobile/ios/ and have followed all the steps that are necessary for sign in!

那么,我如何获得登录Google Plus的当前用户邮件ID?

So, How i get current User Mail ID that is Login In Google plus?

推荐答案

转到GTMOAuth2Authentication.m文件
方法setKeysForResponseDictionary in dic在方法结束时返回访问令牌

go to GTMOAuth2Authentication.m file method setKeysForResponseDictionary in dic returns access token at end of method.

accessTocken = [dict valueForKey:@"access_token"]; // access tocken pass in .pch file
[accessTocken retain];

并在您的控制器中

- (IBAction)momentButton:(id)sender {
  NSString *str =  [NSString stringWithFormat:@"https://www.googleapis.com/oauth2/v1/userinfo?access_token=%@",accessTocken];
  NSString* escapedUrl = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",escapedUrl]];
  NSString *jsonData = [[NSString alloc] initWithContentsOfURL:url usedEncoding:nil error:nil];
  NSMutableDictionary *proDic = [[NSMutableDictionary alloc] init];

  proDic=[jsonData JSONValue];
  NSLog(@"%@",proDic);

这篇关于我已在我的IOS应用程序中集成了google plus,但我无法获取登录的当前用户的电子邮件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆