0 iphone authentication social-networking google-plus ios6
我正在尝试创建一个应用程序,从他的谷歌+帐户中检索当前用户的电子邮件ID,用户ID,用户名.代码的一部分如下,
- (IBAction)googleSigninBtnTapped:(id)sender
{
[GPPSignInButton class];
[GPPSignIn sharedInstance].clientID =[NSString stringWithFormat:@"MY APP ID"];
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
signIn.shouldFetchGoogleUserEmail = YES;
signIn.shouldFetchGoogleUserID = YES;
signIn.actions = [NSArray arrayWithObjects:
@"http://schemas.google.com/AddActivity",
@"http://schemas.google.com/BuyActivity",
@"http://schemas.google.com/CheckInActivity",
@"http://schemas.google.com/CommentActivity",
@"http://schemas.google.com/CreateActivity",
@"http://schemas.google.com/ListenActivity",
@"http://schemas.google.com/ReserveActivity",
@"http://schemas.google.com/ReviewActivity",
nil];
[signIn trySilentAuthentication];
}
(void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError )error
{
if (error)
{
NSLog(@"Status: Authentication error: %@", error);
}
else
{
NSLog(@"Status: Authenticated");
NSLog(@"Email: %@",[GPPSignIn sharedInstance].authentication.userEmail);
GTLServicePlus plusService = [[[GTLServicePlus alloc] init] autorelease];
plusService.retryEnabled = YES;
[plusService setAuthorizer:[GPPSignIn sharedInstance].authentication];
GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"];
[plusService executeQuery:query completionHandler:^(GTLServiceTicket *ticket, GTLPlusPerson *person, NSError *error)
{
if (error)
{
GTMLoggerError(@"Error: %@", error);
}
else
{
[person retain];
NSLog(@"%@", person.displayName);
NSLog(@"%@", person.identifier);
}
}];
}
}
Run Code Online (Sandbox Code Playgroud)
但当我试图执行我的应用程序时,它会崩溃,说
' - [__ NSCFString gtm_stringByUnescapingFromURLArgument]:无法识别的选择器发送到实例0x9e435b0'
任何人都可以帮助我... !!!
提前致谢!!!
是的,你需要-ObjC链接器标志,它没有找到GoogleOpenSource框架中的一个类别.
请参阅设置指南中的第3步:https://developers.google.com/+/mobile/ios/getting-started#step_3_initialize_the_google_client
基本上,在其他链接器标志中,添加-ObjC(大写很重要,请注意!).另外,请确保您已在项目中包含GooglePlus和GoogleOpenSource框架.
| 归档时间: |
|
| 查看次数: |
763 次 |
| 最近记录: |