问题
iOS Google+ SignIn finishedWithAuth never triggered after the application:openURL:sourceApplication:annotation: app delegate method. This was working, but now it does not.
The response is:
url:com.**************:/oauth2callback?state=19139956&code=4/<some token string>&authuser=0&num_sessions=1&prompt=consent&session_state=9efdca9285835ed58ace73b284e4f7521076fc97..4291*
The signIn instance is a class member, so I don't know what happens for the finishedWithAuth triggering.
Thanks!
回答1:
-(void)googlePluseLogin
{
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
signIn.shouldFetchGooglePlusUser = YES;
signIn.shouldFetchGoogleUserEmail = YES;
signIn.clientID = kClientID;
signIn.scopes = @[@"profile"];
if (![signIn trySilentAuthentication])
[signIn authenticate];
}
-(void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
NSLog(@"%@",auth);
if (error)
{
}
else
{
}
}
回答2:
You need to call GPPURLHandler handleURL in your application:openURL:sourceApplication:annotation: method, and you need to have setup the delegate on [GPPSignIn sharedInstance] before. I am guessing that you don't set the delegate until after the GPPURLHandler has been processed.
回答3:
I forgot to setup a URL Type as shown in Step 3
来源:https://stackoverflow.com/questions/25238221/ios-google-signin-finishedwithauth-not-called-after-application-openurl-delegat