OGeek|极客世界-中国程序员成长平台

标题: ios - GIDSignInDelegate 方法不在 iOS 8.4 中调用 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 20:26
标题: ios - GIDSignInDelegate 方法不在 iOS 8.4 中调用

我已经在我的应用中实现了 google signIn

它在 iOS 9+ 中运行良好。但它在 8+ 版本中产生了问题。

我已将 google 登录初始化为:

  [GIDSignIn sharedInstance].uiDelegate = self;
  [GIDSignIn sharedInstance].delegate = self;

在我的 button 点击下面的代码是他们的:

    - (void)userDidTapSignInButtonUIButton*)sender {

        [[GIDSignIn sharedInstance] signIn];

    }

只有这个 Google Delegate 被调用:

    - (void)signInWillDispatchGIDSignIn *)signIn errorNSError *)error {

        NSLog(@"Show Sign In Screen");

   }

在此 Google Sign 页面打开后。当我按下确认和完成时输入我的用户登录详细信息后,我将被重定向回我的应用程序。在这之后什么也没有发生。

没有调用成功和失败的委托(delegate)。

  - (void)signInGIDSignIn *)signIn
          didSignInForUserGIDGoogleUser *)user
 withErrorNSError *)error {
       NSLog(@"Google Sign IN SUccess");
   }

失败代表:

  - (void)signInGIDSignIn *)signIn
     didDisconnectWithUserGIDGoogleUser *)user
 withErrorNSError *)error {
    NSLog(@"google sign in fail with error");
   }

当我在 iOS 9.2 或 9.3 中运行我的应用程序时,它运行良好,每个委托(delegate)都被调用。但在 iOS 8.4、8.3 中没有,...

我无法找出背后的原因。

我也没有在控制台中收到任何日志或错误消息。



Best Answer-推荐答案


你要实现ios 9.0版本和ios 8.0版本的open url功能。

   @available(iOS 8.0,*)
func application(application: UIApplication,
                 openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    print("sign in with annotation")
    return GIDSignIn.sharedInstance().handleURL(url,
                                                sourceApplication: sourceApplication,
                                                annotation: annotation)
}
@available(iOS 9.0, *)
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
    print("sign in with options")
    return GIDSignIn.sharedInstance().handleURL(url,
                                                sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String?,
                                                annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
}

关于ios - GIDSignInDelegate 方法不在 iOS 8.4 中调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37697908/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4