我有一个带有 IBAction 的简单 iOS 应用程序。但是,完成处理程序代码没有运行,我无法弄清楚它为什么没有运行。这是我的代码:
-(IBAction)didTapSignIn:(id)sender {
void (^handler)(id, id, id) = ^(GTMOAuth2ViewControllerTouch *viewController, GTMOAuth2Authentication *auth, NSError *error) {
NSLog(@"TEST 2");
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"AC: %@ \nRT: %@", auth.accessToken, auth.refreshToken);
NSLog(@"AC TOKEN: %@", [GPPSignIn sharedInstance].authentication.accessToken);
NSLog(@"RF TOKEN: %@", [GPPSignIn sharedInstance].authentication.refreshToken);
NSLog(@"KEYCHAIN: %@", [GPPSignIn sharedInstance].keychainName);
}];
NSLog(@"AC: %@ \nRT: %@", auth.accessToken, auth.refreshToken);
NSLog(@"AC TOKEN: %@", [GPPSignIn sharedInstance].authentication.accessToken);
NSLog(@"RF TOKEN: %@", [GPPSignIn sharedInstance].authentication.refreshToken);
NSLog(@"KEYCHAIN: %@", [GPPSignIn sharedInstance].keychainName);
/*
if (error) {
NSLog(@"%@", error);
return;
}
else {
BOOL signedIn = [[GPPSignIn sharedInstance] trySilentAuthentication];
if (!signedIn) {
NSLog(@"Sign In failed");
}
}*/
};
GTMOAuth2ViewControllerTouch *controller = [GTMOAuth2ViewControllerTouch controllerWithScope:@"https://www.googleapis.com/auth/plus.login" clientID:[GPPSignIn sharedInstance].clientID clientSecret:nil keychainItemName:[GPPSignIn sharedInstance].keychainName completionHandler:handler];
NSLog(@"TEST 1");
[self presentViewController:controller animated:YES completion:nil];
NSLog(@"TEST 3");
}
我究竟做错了什么?它应该运行,但它没有。
谢谢你的时间,丹。