gpt4 book ai didi

ios - GIDSignInUIDelegate 被调用的方法

转载 作者:行者123 更新时间:2023-11-28 23:45:50 24 4
gpt4 key购买 nike

我在导航堆栈(第二个子级)上有一个 View Controller 。

Controller 设置为 GIDSignInDelegate 和 GIDSignInUIDelegate。

触发登录后,将调用每个预期调用的委托(delegate)方法,但以下情况除外:

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

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

请注意,在 viewDidLoad 中,我已将 View Controller 指定为委托(delegate)和 ui 委托(delegate)。

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

这是什么原因造成的?

最佳答案

如果问题发生在 iOS 11 及更高版本上,那么我在框架的变更日志文档中找到了这个解释:https://cocoapods.org/pods/GoogleSignIn/changelog

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

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 通过私有(private) API 呈现和取消登录流程,从而使两个回调方法无用。我认为这些方法保留在 GIDSignInUIDelegate 协议(protocol)中只是为了向后兼容 iOS 10,在 iOS 10 中未使用 SFAuthenticationSession ,并且可以在其中显示和忽略登录流程。特定的 View Controller 。

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

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

关于ios - GIDSignInUIDelegate 被调用的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52687644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com