谷歌登录finishedWithAuth只有在点击两次后才会被调用

时间:2014-01-03 15:26:41

标签: ios objective-c google-api google-login

我正在尝试在我的应用上设置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函数时才会调用它。知道为什么会这样吗?

1 个答案:

答案 0 :(得分:1)

看起来像是finishedWithAuth not called after authenticate method

的副本

制作GPPSignIn类级变量,以避免在设备切换到Safari进行登录时收集垃圾。