我正在尝试在我的应用上设置Google
登录,并为此设置了以下功能:
-(void) performGoogleLogin{
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.shouldFetchGooglePlusUser = YES;
signIn.shouldFetchGoogleUserEmail = YES;
signIn.clientID = kClientId;
signIn.scopes = @[ @"email" ];
signIn.delegate = self;
[signIn authenticate];
}
当我第一次执行此操作时,应用会打开Safari
我授予权限的位置。返回我的应用程序后,我的AppDelegate中的这个函数被调用:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
但是,-(void) finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
函数不会立即被调用。只有在我第二次单击我的按钮调用performGoogleLogin
函数时才会调用它。知道为什么会这样吗?
答案 0 :(得分:1)
看起来像是finishedWithAuth not called after authenticate method
的副本制作GPPSignIn类级变量,以避免在设备切换到Safari进行登录时收集垃圾。