我在我的应用中使用谷歌登录。我已经通过firebase配置了链接https://firebase.google.com/docs/auth/ios/google-signin中给出的步骤。我的问题是,当我在iPhone中打开我的应用程序时,它会重定向到移动浏览器并且工作得很好。但是当我在iPad上打开应用程序时,它会在Webview中打开,因此会出现用户代理问题。
有人可以建议我如何强制该应用程序进入浏览器,即使它在iPad中打开。
我附上了我的代码以供参考
@available(iOS 9.0, *)
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any])
-> Bool
{
return GIDSignIn.sharedInstance().handle(url,
sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
annotation: [:])
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
{
return GIDSignIn.sharedInstance().handle(url,
sourceApplication: sourceApplication,
annotation: annotation)
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?)
{
if error != nil {
// ...
print(error!)
return
}
guard let authentication = user.authentication else { return }
let credential = FIRGoogleAuthProvider.credential(withIDToken: authentication.idToken,
accessToken: authentication.accessToken)
FIRAuth.auth()?.signIn(with: credential) { (user, error) in
print(user!)
GIDSignIn.sharedInstance().signOut()
self.view.hideToastActivity()
self.getUserDetails(email: (user?.email)!)
if error != nil {
// ...
print(error!)
return
}
}
}
func sign(_ signIn: GIDSignIn!, didDisconnectWith user:GIDGoogleUser!,
withError error: Error!) {
// Perform any operations when the user disconnects from app here.
// ...
if error != nil {
// ...
print(error)
return
}
}