在swift中单击“继续”后,Firebase Google登录无法打开身份验证

时间:2018-03-12 16:27:38

标签: ios swift firebase firebase-authentication

我正在视图控制器上实现Swift中的firebase google登录。实施后我收到了权限提示警报,但是一旦点击继续警报就没有发生任何事情只是关闭警报视图。 Facebook登录也是如此。有什么想法吗?

enter image description here


提前致谢

的AppDelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    FirebaseApp.configure()

    GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
    GIDSignIn.sharedInstance().delegate = self

    // Override point for customization after application launch.
    return true
}

的ViewController

override func viewDidLoad() {
    GIDSignIn.sharedInstance().uiDelegate = self
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
    // ...
    if let error = error {
        // ...
        return
    }

    guard let authentication = user.authentication else { return }
    let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
                                                   accessToken: authentication.accessToken)
    // ...
}
@IBAction func signInClick(_ sender: Any) {
    GIDSignIn.sharedInstance().signIn()
}

在做了一些调试之后我发现在点击继续之后,它试图调用SFSafariViewController,但是没有显示SafariViewController。

截图

enter image description here enter image description here

1 个答案:

答案 0 :(得分:0)

最后,我发现了这个问题。该应用程序持有两个UIWindow,Google / Facebook登录webview正在添加到一个不可见的UIWindow。

enter image description here

我已经解决了这个问题,
谢谢!
拉梅什