[英]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.