如何在 iOS 上使用 Sign In with Google 修复“用户取消了登录流程。”?

     2023-02-23     73

关键词:

【中文标题】如何在 iOS 上使用 Sign In with Google 修复“用户取消了登录流程。”?【英文标题】:How to fix `The user canceled the sign-in flow.` with Sign In with Google on iOS? 【发布时间】:2019-07-15 08:24:17 【问题描述】:

我正在将 Sign in with Google 与 iOS Firebase SDK 集成。当用户点击GIDSignIn 按钮时,应用程序会显示一个显示"MyAPP" want to use Google.com for Sign in 的警报,但警报会很快消失。我在didSignInFor user: GIDGoogleUser方法中得到的错误如下:

2019-02-21 16:54:13.104279+0530 MyApp[18743:185089] [Warning] Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<SFAuthenticationViewController: 0x7fa327945800>)
[DEBUG] Google sign-in error: Error Domain=com.google.GIDSignIn Code=-5 "The user canceled the sign-in flow." UserInfo=NSLocalizedDescription=The user canceled the sign-in flow.

我已遵循Authenticate Using Google Sign-In on iOS 文档。

我也试过Google Sign-In crashes on iOS 9 attempting to call canOpenURL的答案,但它不起作用。

AppDelegate 也实现了GIDSignInUIDelegate

如果我从GIDSignInButton to UIButton 更改按钮,它可以工作,但样式会丢失。

【问题讨论】:

【参考方案1】:

如果您尝试在@IBAction 中运行GIDSignIn.sharedInstance()?.signIn()。您可以在登录前运行 GIDSignIn.sharedInstance()?.presentingViewController = self 而不是 insideviewDidLoad()

@IBAction func googleLogin(_ sender: UIButton) 
    GIDSignIn.sharedInstance()?.presentingViewController = self
    GIDSignIn.sharedInstance()?.signIn()

【讨论】:

【参考方案2】:

我之前也遇到过这个问题。 GIDSignInButton 对象在代码中不需要addTarget 或链接@IBActionGIDSignInButton 类已经为我们处理了该操作。

【讨论】:

【参考方案3】:

Appdelegate 尝试使用下面的代码

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool 

    let result = GIDSignIn.sharedInstance().handle(url,
                                                    sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                                                    annotation: options[UIApplication.OpenURLOptionsKey.annotation])
    return result


【讨论】:

在为 iOS 编译时,如何让 Unity 自动添加 Sign In With Apple 功能?

】在为iOS编译时,如何让Unity自动添加SignInWithApple功能?【英文标题】:HowcanIgetUnitytoautomaticallyaddtheSignInWithApplecapabilitywhencompilingforiOS?【发布时间】:2020-08-0206:17:45【问题描述】:我已经在谷歌上搜索了几个小时并尝试了我能想... 查看详情

如何更改“Sign In with Apple”按钮的宽度?

】如何更改“SignInwithApple”按钮的宽度?【英文标题】:HowdoIchangethewidthofthe"SignInwithApple"button?【发布时间】:2019-07-1816:37:40【问题描述】:我在SwiftUI中嵌入了一个“使用Apple登录”按钮,使用UIViewRepresentable结构来显示按... 查看详情

如何配置 Mailgun 以与 Sign in with Apple 和 Apple 的中继服务一起使用?

】如何配置Mailgun以与SigninwithApple和Apple的中继服务一起使用?【英文标题】:HowtoconfigureMailguntobeusedwithSigninwithAppleandApple\'srelayservice?【发布时间】:2020-05-2306:21:27【问题描述】:我已按照Apple文档中的说明验证了我的域,但我仍... 查看详情

如何在 mac M1(Apple 芯片)上使用 google_sign_in api 进行开发

】如何在macM1(Apple芯片)上使用google_sign_inapi进行开发【英文标题】:howtodevelopusinggoogle_sign_inapionmacM1(Applesilicon)【发布时间】:2021-11-0300:27:33【问题描述】:我最近开始在M1mac上使用颤振开发一个项目,我所有的依赖项都可以正... 查看详情

使用 Apple 登录按钮标题始终显示“SIGN_IN_WITH_APPLE”

】使用Apple登录按钮标题始终显示“SIGN_IN_WITH_APPLE”【英文标题】:SigninwithApplebuttontitlealwaysdisplays"SIGN_IN_WITH_APPLE"【发布时间】:2020-09-1200:21:39【问题描述】:我有一个应用程序本地化为两种语言:英语和立陶宛语。我正... 查看详情

Android Sign in with apple and firebase flutter

...】:【发布时间】:2020-10-2911:38:19【问题描述】:我正在使用sign_in_with_apple并且我的登录功能适用于ios,但android组件无法正常工作。我已经查看了提出此问题的文档和问题,但没有明确的答案。https://github.com/aboutyou/dart_packages/tr... 查看详情

不允许重定向 url localhost 和 127.0.0.1 时如何在 Unity 中从 Sign in with Apple 获取代码

】不允许重定向urllocalhost和127.0.0.1时如何在Unity中从SigninwithApple获取代码【英文标题】:HowtogetcodefromSigninwithAppleinUnitywhenredirecturlslocalhostand127.0.0.1arenotpermitted【发布时间】:2020-03-1515:48:14【问题描述】:我正在尝试在Unity编辑器... 查看详情

iOS Native Sign In With Apple token 返回 bundle ID 作为受众而不是服务 ID

...SignInWithApple添加到其中。我能找到的一切都表明我们需要使用服务I 查看详情

我可以隐藏 Sign In with Apple 按钮的文本吗? (又名 ASAuthorizationAppleIDButton)?

】我可以隐藏SignInwithApple按钮的文本吗?(又名ASAuthorizationAppleIDButton)?【英文标题】:CanIhidethetextoftheSignInwithApplebutton?(a.k.aASAuthorizationAppleIDButton)?【发布时间】:2021-04-2410:10:14【问题描述】:我正在我的iOS应用(SwiftUI)上实现Si... 查看详情

Flutter Web:google_sign_in_web:适用于桌面和 iOS。在 Android Chrome 上失败

】FlutterWeb:google_sign_in_web:适用于桌面和iOS。在AndroidChrome上失败【英文标题】:FlutterWeb:google_sign_in_web:WorksondesktopandiOS.FailsonAndroidChrome【发布时间】:2021-01-0420:58:34【问题描述】:链接到Firebase的简单身份验证代码。该代码在移... 查看详情

为 android 配置 Flutter“sign_in_with_apple”时出现问题

】为android配置Flutter“sign_in_with_apple”时出现问题【英文标题】:ProblemconfiguringFlutter"sign_in_with_apple"forandroid【发布时间】:2020-12-1411:46:08【问题描述】:我正在尝试设置Fluttersign_in_with_apple包,但在android端遇到问题。到目... 查看详情

如何在 Flutter 的 google_sign_in 中获取 JWT 格式的访问令牌?

】如何在Flutter的google_sign_in中获取JWT格式的访问令牌?【英文标题】:HowtogetanaccesstokeninJWTformatinFlutter\'sgoogle_sign_in?【发布时间】:2021-07-2014:47:39【问题描述】:我正在验证对GCPCloudEndpoints后面的GCP上运行的私有API的调用,如here... 查看详情

使用 Apple 登录 - Ionic 3

】使用Apple登录-Ionic3【英文标题】:SignInWithApple-Ionic3【发布时间】:2020-07-1219:54:24【问题描述】:我正在尝试使用以下插件和包装器在我的ionic3项目上使用苹果实现登录ioniccordovapluginaddcordova-plugin-sign-in-with-applenpmi--save@ionic-native... 查看详情

MissingPluginException(在通道 plugins.flutter.io/google_sign_in 上找不到方法 init 的实现)

】MissingPluginException(在通道plugins.flutter.io/google_sign_in上找不到方法init的实现)【英文标题】:MissingPluginException(Noimplementationfoundformethodinitonchannelplugins.flutter.io/google_sign_in)【发布时间】:2018-06-2919:31:54【问题描述】:使用Flutt 查看详情

为啥我不能将动作附加到情节提要中的新 Sign In With Apple ASAuthorizationAppleIDButton?

】为啥我不能将动作附加到情节提要中的新SignInWithAppleASAuthorizationAppleIDButton?【英文标题】:Whycan\'tIattachanactiontothenewSignInWithAppleASAuthorizationAppleIDButtoninaStoryboard?为什么我不能将动作附加到情节提要中的新SignInWithAppleASAuthorization... 查看详情

Flutter登录Apple无法在iOS模拟器上运行(无限加载器)

...oader)【发布时间】:2021-01-1813:36:42【问题描述】:我正在使用sign_in_with_apple。在iOS模拟器(软件版本14.0)上遇到问题。输入密码并点击“继续”后会显示无限加载程序。流量卡住了。接下来什么也没有发生 查看详情

Flutter - 使用 google_sign_in 库时未找到 <Flutter/Flutter.h>

】Flutter-使用google_sign_in库时未找到<Flutter/Flutter.h>【英文标题】:Flutter-<Flutter/Flutter.h>notfoundwhenusingthegoogle_sign_inlibrary【发布时间】:2019-09-2222:43:17【问题描述】:我在为ios编译应用程序时遇到了这个问题这是整个堆栈... 查看详情

在 System.in 中使用 try-with-resources [重复]

...时关闭它(一旦win=true),它会关闭系统。在流中,我该如何防止呢?publicfin 查看详情