简体   繁体   English

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

[英]How can I redirect back to my app after the user has verified their email using Firebase Auth and Swift?

When a user signs up in my app, they get a pop up that says, please verify your email and then login. 当用户注册我的应用程序时,他们会弹出一个窗口,提示您,请验证您的电子邮件,然后登录。 When the user clicks OK, it takes them to login page. 当用户单击“确定”时,将带他们进入登录页面。 At this point the user should go to the Mail app (iPhone) and click the link that has been sent to them from Firebase. 此时,用户应转到“邮件”应用(iPhone)并单击从Firebase发送给他们的链接。 Clicking this link currently opens Safari and tells the user the account is verified, then the user has to manually go back to the app. 单击此链接当前会打开Safari,并告诉用户该帐户已通过验证,然后用户必须手动返回到该应用程序。 How can I verify the user AND then also take them back to the app? 如何验证用户,然后又将他们带回应用程序?

I've read up about continueURL and also the documentation that Firebase provides but it just doesn't make any sense and I'm getting confused on what I need to do. 我已经阅读了有关continueURL以及Firebase提供的文档的信息,但它没有任何意义,我对需要做的事情感到困惑。 If someone can explain how to do this is in simpler terms that would be much appreciated. 如果有人可以用更简单的方式解释这一点,将不胜感激。

This is how I'm sending out the email: user?.sendEmailVerification(completion: nil) 这是我发送电子邮件的方式:user?.sendEmailVerification(完成:无)

Thank you in advance for your help! 预先感谢您的帮助!

you can have the link directly take you to the iOS app but handle the code in the app by setting handleCodeInApp to YES . 您可以使链接直接将您带到iOS应用程序,但可以通过将handleCodeInApp设置为YES来处理应用程序中的代码。 For simplicity, let's illustrate how to first open the link in the web page ( handleCodeInApp is NO which is the default), verify the email and then redirect back to the mobile app to continue to the user's intended destination. 为简单起见,让我们说明如何首先打开网页中的链接( 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.
})

In the above flow, the verification link will be sent to the user. 在上述流程中,验证链接将发送给用户。 User will click the link. 用户将单击链接。 It will open the provisioned web page where the email will be verified. 它将打开预配置的网页,将在其中验证电子邮件。 A continue button is shown which on click, if the iOS app is installed on the device, will redirect back to the app. 将显示一个继续按钮,如果该设备上安装了iOS应用,则单击该按钮将重定向回该应用。

You will use Firebase dynamic link to intercept that link. 您将使用Firebase动态链接来拦截该链接。 Learn more about configuring FDL in iOS and handling the link here: 在此处了解有关在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 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

The Firebase dynamic link will have a deep link with the following URL: https://www.example.com/?email=%@", user.email Firebase动态链接将具有带有以下URL的深层链接: https://www.example.com/?email=%@", user.email : https://www.example.com/?email=%@", user.email

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift Firebase:如何在发送电子邮件后检查用户是否经过验证? - Swift Firebase: how to check user is verified after send email? 使用Swift和Firebase,如何从经过身份验证的应用程序用户向自己发送自动电子邮件? - Using Swift and Firebase, how can I send an automated email to myself from an authenticated user of my app? Firebase 电话验证错误“APP_NOT_VERIFIED” - Firebase phone auth error "APP_NOT_VERIFIED" 如何使用Swift在Firebase中更新用户的分数? - How can I update user's score in Firebase using Swift? 如何检查用户电子邮件是否已验证? - How to check if user email verified? Swift Firebase-如何验证`PhoneAuthCredential`并保持用户当前使用其当前电子邮件uid登录 - Swift Firebase -How can I verify the `PhoneAuthCredential` and keep the user currently signed in with their current email uid 迅捷将图像移回中间后,如何带上图像? 或将其旋转回原点位置 - Swift How can I bring my Image after moving it back to the Middle ? Or rotate it back to the Origin position 如何在Swift中使用Firebase对用户电子邮件和密码进行身份验证 - How to authenticate user email and password using Firebase in Swift 我如何在我的应用程序中添加一个即使用户已卸载Mail.app也能正常工作的电子邮件链接? - How do I add an email link in my app that works even if the user has uninstalled Mail.app? 如何将点击电子邮件链接的用户巧妙地重定向到我的应用程序或移动网站? - How can I smartly redirect users who click on an email link, to my app or my mobile site?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM