接受权限后,Google登录SFSafariViewController/WebView重定向到Google.com [英] Google SignIn SFSafariViewController/WebView redirects to Google.com after accepting permissions

查看:82
本文介绍了接受权限后,Google登录SFSafariViewController/WebView重定向到Google.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施使用Cocoapods安装的新Google登录库.部署目标是8.4,并且在9.0.2设备中进行Im测试.

Im trying to implement the new Google SignIn Library that I installed using Cocoapods. Deployment Target is 8.4 and Im testing in a 9.0.2 device.

1-我有正确的带有客户端ID和反向ID的plist文件

1- I have the proper plist file with clientID and reverseID

2-我已设置了网址类型

2- I have the URL types set

3-我将AppDelegate作为GIDSignIn [GIDSignIn sharedInstance].delegate = self;的委托,并实施了适当的委托方法来捕获回调- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error

3- I have the AppDelegate as a delegate of GIDSignIn [GIDSignIn sharedInstance].delegate = self; and the proper delegate methods implemented to catch the callback - (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error

4-我有- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation]; }

4- I have the - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation]; }

5-我使用自动GIDSignInButton类,并将其放置在UIViewController的子类中,因此我不需要实现GIDSignIn uiDelegate方法.但是我在viewDidLoad中仍然设置了[[GIDSignIn sharedInstance] setUiDelegate:self];

5- Im using the automatic GIDSignInButton class and is placed in a subclass of UIViewController, so I dont need to implement the GIDSignIn uiDelegate methods. But I still have [[GIDSignIn sharedInstance] setUiDelegate:self]; set in the viewDidLoad

6-我在链接库中有SFSafariViewController.framework.

6- I have SFSafariViewController.framework in the Linked Libraries.

7-我从不手动将clientID设置为GIDSignIn,因为这不是Google官方文档中的说明的一部分.尽管许多人继续这样做,但我不知道为什么.

7- I never manually set the clientID to GIDSignIn because that is not part of the instructions at google's official documentation. Although many people keep doing it I dont know why.

问题:一旦按下登录按钮,就会显示SFSafariViewController,我选择了要使用的帐户(请注意,即使安装了多个帐户,它也不会从我的应用程序进入任何其他Google应用程序进行身份验证).显示权限,我看到名称&我在Google Developer Console中配置的应用的徽标,我接受许可. SFSafariViewController退回到"www.google.com",仅此而已.退出此屏幕的唯一方法是,点击上端右上角的确定"按钮,然后调用- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error,错误提示已使用的已取消登录过程.

The Problem: Once I press the Login button, a SFSafariViewController gets presented, I select the account I want to use (notice it never went out of my app into any other google apps for authentication even though I have several installed). The permissions get presented, I see the name & logo of my app that I configured in Google Developer Console, I accept the permissions. The SFSafariViewController falls back to "www.google.com" and thats it. The only way to dismiss this screen is to tap on the "OK" button in the uppper right corner, and then the - (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error gets called, with error saying the used Cancelled the login process.

推荐答案

只需解决.使用CocoaPods时,似乎必须设置

Just solve it. As you are using CocoaPods, seems like you have to set

迅速:

 func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: sourceApplication, annotation: annotation)
}

Obj-c

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

在您的appDelegate中.现在,接受权限后,您将被重定向到您的应用.

in your appDelegate. Now you will be redirected to your app after accepting the permissions.

更多信息: https://developers.google.com/identity /sign-in/ios/signin

这篇关于接受权限后,Google登录SFSafariViewController/WebView重定向到Google.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆