我正在尝试创建一个应用程序,从他的 google+ 帐户中检索当前用户的电子邮件 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);
}
}];
}
}
但是当我试图执行我的应用程序时,它会崩溃,说
'-[__NSCFString gtm_stringByUnescapingFromURLArgument]: 无法识别的选择器发送到实例 0x9e435b0'
任何人都可以帮我解决这个问题...!!!
提前致谢!!!