应用程序openURL委托后未调用iOS Google+ SignIn finishedWithAuth

时间:2014-08-11 07:49:58

标签: ios objective-c google-plus

{p> iOS Google+ SignIn finishedWithAuth从未在application:openURL:sourceApplication:annotation: app委托方法之后触发。这是有效的,但现在却没有。

回复是:

url:com.**************:/oauth2callback?state=19139956&code=4/<some token string>&authuser=0&num_sessions=1&prompt=consent&session_state=9efdca9285835ed58ace73b284e4f7521076fc97..4291*

signIn个实例是一个类成员,所以我不知道finishedWithAuth触发会发生什么。

谢谢!

3 个答案:

答案 0 :(得分:2)

  -(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
    {
    }

}

答案 1 :(得分:0)

您需要在GPPURLHandler handleURL方法中致电application:openURL:sourceApplication:annotation:,并且您需要先在[GPPSignIn sharedInstance]设置委托。我猜你在处理完GPPURLHandler之后才设置代理。

答案 2 :(得分:0)

我忘了设置网址类型,如Step 3

所示