GPPSignIn iOS失败

时间:2014-07-26 14:03:11

标签: ios oauth-2.0 google-plus

我正在尝试将google plus登录集成到iOS应用程序中。我已为我的应用设置了凭据,添加了一个包含我的应用程序包ID的网址类型,并按照Google开发人员文档中详细说明进行操作。

在我的ViewController中:

  • 在头文件中,我已将ViewController声明为<GPPSignInDelegate>
  • 在.m文件中,我使用来自开发人员门户网站的clientId创建了变量kClientId
  • viewDidLoad方法中,我添加了以下内容:

    [GPPSignIn sharedInstance].clientID = kClientId;
    [GPPSignIn sharedInstance].scopes = @[ @"profile"];
    [GPPSignIn sharedInstance].shouldFetchGoogleUserEmail = YES;
    [GPPSignIn sharedInstance].delegate = self;
    
  • 在我的登录按钮点击处理程序中,我致电

    [[GPPSignIn sharedInstance] authenticate]
    
  • 我已经实现了方法

    finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error

    (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion

在我的AppDelegate中,我添加了以下内容:

- (BOOL)application: (UIApplication *)application
        openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication
         annotation: (id)annotation { 
            return [GPPURLHandler handleURL:url 
                    sourceApplication:sourceApplication
                    annotation:annotation]; }

此方法的返回值始终为&#34;否&#34;和GPPSignIn委托方法

finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
永远不会打电话给

。我的应用程序重定向到登录页面,登录后显示没有错误代码,只是重定向回我的应用程序中的原始视图。我在登录后检查了[[GPPSignIn sharedInstance] hasAuthInKeychain]属性,结果为false。我已经在AppDelegate.m中检查过GPPSignInDelegate设置为我的视图控制器,它是。在查看了一些帖子后,我为[[GPPSignIn sharedInstance]值创建了一个类级变量,但不管结果是什么。谁能告诉我这里缺少什么?

0 个答案:

没有答案