gpt4 book ai didi

ios - 在用户使用 Firebase Auth 和 Swift 验证了他们的电子邮件后,我如何重定向回我的应用程序?

转载 作者:可可西里 更新时间:2023-11-01 00:39:34 25 4
gpt4 key购买 nike

当用户在我的应用程序中注册时,他们会看到一个弹出窗口,提示请验证您的电子邮件,然后登录。当用户单击“确定”时,会将他们带到登录页面。此时,用户应该转到邮件应用程序 (iPhone) 并单击从 Firebase 发送给他们的链接。单击此链接当前会打开 Safari 并告诉用户帐户已通过验证,然后用户必须手动返回应用程序。我如何才能验证用户并将他们带回应用程序?

我已经阅读了有关 continueURL 以及 Firebase 提供的文档,但它没有任何意义,我对我需要做什么感到困惑。如果有人能用更简单的术语解释如何做到这一点,我们将不胜感激。

这就是我发送电子邮件的方式:user?.sendEmailVerification(completion: nil)

预先感谢您的帮助!

最佳答案

您可以让链接直接将您带到 iOS 应用程序,但通过将 handleCodeInApp 设置为 YES 来处理应用程序中的代码。为简单起见,让我们说明如何首先在网页中打开链接(handleCodeInAppNO,这是默认设置),验证电子邮件,然后重定向回移动应用程序继续前往用户的预定目的地。

var actionCodeSettings =  ActionCodeSettings.init()
actionCodeSettings.canHandleInApp = false
let user = Auth.auth().currentUser()
// This URL will be the deep link of the FDL. It is useful for
// passing state back to your iOS app to let it know that you were
// verifying a user of email user.email. This is also useful
// in case the user clicks the continue button a non iOS device.
// You should own this link.
actionCodeSettings.URL =
String(format: "https://www.example.com/?email=%@", user.email)
// This is your iOS app bundle ID. It will try to redirect to your
// app via Firebase dynamic link.
actionCodeSettings.setIOSBundleID("com.example.ios")
user.sendEmailVerification(withActionCodeSettings:actionCodeSettings { error in
if error {
// Error occurred. Inspect error.code and handle error.
return
}
// Email verification sent.
})

在上面的流程中,验证链接会发送给用户。用户将单击该链接。它将打开配置的网页,其中将验证电子邮件。显示一个继续按钮,如果设备上安装了 iOS 应用程序,单击该按钮将重定向回该应用程序。

您将使用 Firebase 动态链接拦截该链接。在此处了解有关在 iOS 中配置 FDL 和处理链接的更多信息:

https://firebase.google.com/docs/dynamic-links/ios/receive https://firebase.google.com/docs/auth/ios/passing-state-in-email-actions#configuring_firebase_dynamic_links

Firebase 动态链接将与以下 URL 建立深层链接:https://www.example.com/?email=%@", user.email

关于ios - 在用户使用 Firebase Auth 和 Swift 验证了他们的电子邮件后,我如何重定向回我的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46992992/

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