如何修复`用户取消了登录流程。在iOS上使用Google登录?

问题描述 投票:2回答:2

我正在使用iOS Firebase SDK集成登录Google。当用户点击GIDSignIn按钮时,应用程序会显示一条显示"MyAPP" want to use Google.com for Sign in的警报,但警报很快就会消失。我在didSignInFor user: GIDGoogleUser方法中得到的错误如下:

2019-02-21 16:54:13.104279+0530 MyApp[18743:185089] [Warning] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<SFAuthenticationViewController: 0x7fa327945800>)
[DEBUG] Google sign-in error: Error Domain=com.google.GIDSignIn Code=-5 "The user canceled the sign-in flow." UserInfo={NSLocalizedDescription=The user canceled the sign-in flow.}

我已经关注了Authenticate Using Google Sign-In on iOS文档。

我也在Google Sign-In crashes on iOS 9 attempting to call canOpenURL尝试了答案,但它没有用。

AppDelegate也实现了GIDSignInUIDelegate

如果我从GIDSignInButton to UIButton更改按钮,它可以工作,但样式丢失了。

ios swift google-signin
2个回答
3
投票

我之前也遇到过这个问题。 GIDSignInButton对象在代码中不需要addTarget或链接@IBActionGIDSignInButton类已经为我们处理了这个动作。


0
投票

Appdelegate尝试使用以下代码

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {

    let result = GIDSignIn.sharedInstance().handle(url,
                                                    sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                                                    annotation: options[UIApplication.OpenURLOptionsKey.annotation])
    return result

}
© www.soinside.com 2019 - 2024. All rights reserved.