GIDSignInUIDelegate调用方法 [英] GIDSignInUIDelegate Methods to getting called

查看:57
本文介绍了GIDSignInUIDelegate调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在导航堆栈(第二个孩子)上有一个视图控制器.

I have a view controller on a navigation stack (2nd child).

将控制器设置为GIDSignInDelegate和GIDSignInUIDelegate.

Controller is setup as GIDSignInDelegate and GIDSignInUIDelegate.

触发登录后,将调用每个预期要调用的委托方法,除了:

After triggering sign-in, every delegate method expected to be called, is called, except for:

func sign(_ signIn: GIDSignIn!, present viewController: UIViewController!)

func sign(_ signIn: GIDSignIn!, dismiss viewController: UIViewController!)

请注意,在viewDidLoad中,我已将视图控制器分配为委托和ui委托.

Note that in viewDidLoad I have assigned the view controller to be the delegate and ui delegate.

此外,在关闭Google登录视图后,我当前的视图控制器会自动从导航堆栈(?????)中弹出

Also, after dismissing the Google Sign-In view, my current view controller is automatically popped off the navigation stack (?????)

是什么原因造成的?

推荐答案

如果问题在iOS 11和更高版本上发生,那么我在框架的changelog文档中找到了以下解释:

If the issue is occurring on iOS 11 and higher then I found this explanation in the changelog document of the framework: https://cocoapods.org/pods/GoogleSignIn/changelog

2017年10月17日的条目-v4.1.1指出:

Entry from 2017-10-17 -- v4.1.1 states:

修复了GIDSignInUIDelegate的signInWillDispatch:error:是的问题 未在iOS 11上调用.请注意,这既不是 signIn:presentViewController:或signIn:dimissViewController:被调用 在iOS 11上,因为应用程序的视图未显示SFAuthenticationSession 控制器.

Fixes an issue that GIDSignInUIDelegate's signInWillDispatch:error: was not called on iOS 11. Please note that it is intended that neither signIn:presentViewController: nor signIn:dimissViewController: is called on iOS 11 because SFAuthenticationSession is not presented by the app's view controller.

根据上述说明,确实调用了signInWillDispatch:error,但没有故意故意调用signIn:presentViewController:signIn:dimissViewController:,因为底层的SFAuthenticationSession通过私有API呈现和拒绝登录流使这两个回调方法无用.我认为这些方法仅保留在GIDSignInUIDelegate协议中是为了与不使用SFAuthenticationSession的iOS 10向后兼容,并且可以在特定的视图控制器中显示和取消登录流程.

According to the above explanation signInWillDispatch:error is indeed called, but signIn:presentViewController: and signIn:dimissViewController: are intentionally not called because the underlying SFAuthenticationSession presents and dismisses sign-in flow through private API rendering the two callback methods useless. I suppose these methods are remaining in the GIDSignInUIDelegate protocol solely for the sake of backwards compatibility with iOS 10 where SFAuthenticationSession was not used and the sign in flow could be presented and dismissed from a particular view controller.

但是,即使从未在iOS 11及更高版本上调用这两种方法,当委托对象不是UIViewController的子类时,仍然需要实现这两种方法,否则应用程序将崩溃.显然,实现什么都不做的方法不是很合逻辑.

However even though the two methods never get called on iOS 11 and higher they still need to be implemented when the delegate object is not a subclass of UIViewController, otherwise the app will crash. Obviously it's not very logical to have methods implemented which do nothing...

顺便说一句,Google在更新文档方面可以做得更好,因为现在它具有误导性: https://developers.google.com/identity/sign-in/ios/api/protocol_g_i_d_sign_in_u_i_delegate-p#a2b265097a3c78e7f82d57b2ccda11c39

On a side note, Google could do a better job at updating their documentation because now it is rather misleading: https://developers.google.com/identity/sign-in/ios/api/protocol_g_i_d_sign_in_u_i_delegate-p#a2b265097a3c78e7f82d57b2ccda11c39

这篇关于GIDSignInUIDelegate调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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