gpt4 book ai didi

android - Google 登录 iOS 帐户选择器

转载 作者:可可西里 更新时间:2023-11-01 03:32:47 27 4
gpt4 key购买 nike

我在我的 iOS 应用中使用 Google 登录。我遵循了 Google 教程 ( https://developers.google.com/identity/sign-in/ios/sign-in#add_the_sign-in_button ),该教程使用用户必须单击的 GIDSignInButton。当他点击它时,他被重定向到 Safari,如下所示:

enter image description here

问题在于我有多个 Google 帐户,并且希望能够选择我想使用的帐户。现在它只是自动接受其中之一,我所要做的就是按“拒绝”或“允许”。此外,我不喜欢应用程序被重定向到 Chrome 的事实。理想情况下,我想要的是类似于 iOS 上的 Google Hangouts 应用程序的功能:

enter image description here

它会显示您之前用于登录任何 Google 应用程序的所有帐户,并让您在不离开应用程序的情况下决定将哪些帐户用于该应用程序。在 Android 上,我的应用程序有类似的功能:

enter image description here

如何在我的 iOS 应用中实现这种行为(不要离开应用 + 帐户选择器)?

最佳答案

他们之所以能够在 Google Hangouts 中做到这一点,是因为它是由 Google 制作的。公司并不总是向开发人员提供所有功能,这就是一个很好的例子。您能够在 android 中执行此操作的原因是因为 Google 决定允许开发人员更多地访问不同的功能。毕竟android是谷歌开发的。现在至于不离开应用程序,您始终可以使用嵌入式 Web View 。这将使用户留在应用程序中,而不是模态地弹出一个 WebView 。它不是世界上最好的,但比将用户发送到其他地方要好。您是否尝试过此代码:

// Implement these methods only if the GIDSignInUIDelegate is not a subclass of
// UIViewController.

// Stop the UIActivityIndicatorView animation that was started when the user
// pressed the Sign In button
func signInWillDispatch(signIn: GIDSignIn!, error: NSError!) {
myActivityIndicator.stopAnimating()
}

// Present a view that prompts the user to sign in with Google
func signIn(signIn: GIDSignIn!,
presentViewController viewController: UIViewController!) {
self.presentViewController(viewController, animated: true, completion: nil)
}

// Dismiss the "Sign in with Google" view
func signIn(signIn: GIDSignIn!,
dismissViewController viewController: UIViewController!) {
self.dismissViewControllerAnimated(true, completion: nil)
}

我在您发布的链接上找到了这个。我没有运行或测试代码,但它似乎显示了一个 View Controller ,而不是将您发送到 safari。这可能更符合您的要求。

回答@Sam 的问题:

“如何通过现有已安装的 Google 应用程序而不是在 Safari 中打开 URL 来登录 Google?”

您可能可以使用 Android 来完成此操作,但不能使用 iOS。这是由于所选平台而受到限制的另一个示例。

请记住,无论您最终选择什么选项,您仍然需要遵守 OAuth 2.0。如果可能的话,我会建议使用谷歌为 iOS 开发者构建的东西。在选择与默认帐户不同的帐户时,如果您选择遵循指南并执行 Google 为 iOS 开发人员创建的内容,那么您只需点击个人资料图片并切换帐户即可。

长话短说

https://www.youtube.com/watch?time_continue=227&v=-26DGO_E1ds

关于android - Google 登录 iOS 帐户选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36452773/

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