Sah*_*cha 8 ios firebase swift firebase-authentication
当用户在我的应用程序中注册时,他们会收到一个弹出窗口,上面写着,请验证您的电子邮件,然后登录。当用户单击“确定”时,会将他们带到登录页面。此时,用户应该转到邮件应用 (iPhone) 并单击从 Firebase 发送给他们的链接。单击此链接当前会打开 Safari 并告诉用户帐户已验证,然后用户必须手动返回应用程序。如何验证用户,然后将他们带回应用程序?
我已经阅读了 continueURL 以及 Firebase 提供的文档,但它没有任何意义,我对我需要做什么感到困惑。如果有人可以用更简单的术语解释如何做到这一点,我们将不胜感激。
这就是我发送电子邮件的方式: user?.sendEmailVerification(completion: nil)
预先感谢您的帮助!
您可以让链接直接将您带到 iOS 应用程序,但通过设置handleCodeInApp为 来处理应用程序中的代码YES。为简单起见,我们说明了如何首先打开的网页的链接(handleCodeInApp是NO这是默认值),验证电子邮件,然后重定向回移动应用程序,继续到用户的目的地。
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.
})
Run Code Online (Sandbox Code Playgroud)
在上述流程中,验证链接将发送给用户。用户将单击该链接。它将打开已配置的网页,将在其中验证电子邮件。将显示一个继续按钮,单击该按钮后,如果设备上安装了 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 动态链接将包含一个包含以下网址的深层链接:
https://www.example.com/?email=%@", user.email
| 归档时间: |
|
| 查看次数: |
4410 次 |
| 最近记录: |