【发布时间】:2018-12-13 03:38:04
【问题描述】:
我正在尝试实现对用户电子邮件的验证(使用电子邮件模板中的默认验证 URL)和 ActionCodeSetting URL(动态链接)以将用户带回应用程序。我对 Firebase 使用 ActionCodeSetting 的电子邮件验证应该如何工作感到困惑。我已经阅读了所有可用的文档页面,但我仍然不清楚如何正确配置“继续 URL”以不抢占并覆盖默认验证 URL。
我做了什么:
- 我使用自动生成的电子邮件验证链接测试了电子邮件验证。有效。
- 然后我添加了一个 ActionCodeSetting URL,该 URL 使用添加到 XCode 项目的关联域中的域。这有助于在单击验证链接后将用户带回应用程序。
- 问题:电子邮件验证不再有效。
这是我实现的代码:
var actionCodeSettings = ActionCodeSettings.init()
actionCodeSettings.handleCodeInApp = true
let user = Auth.auth().currentUser
let urlString = "https://blaproject.page.link/zCB4"
actionCodeSettings.setIOSBundleID(Bundle.main.bundleIdentifier!)
actionCodeSettings.setAndroidPackageName("com.example.android", installIfNotAvailable:true, minimumVersion:"12")
Auth.auth().currentUser?.sendEmailVerification(with: actionCodeSettings, completion: { (error) in
print("verification email sent")
print("action code setting URL is: \(String(describing: actionCodeSettings.url))")
})
这是 Firebase 控制台中电子邮件模板的默认验证网址:
https://blaproject-ea9d6.firebaseapp.com/__/auth/action?mode=&oobCode=
这是上面代码发送的验证 URL:
所以我的问题是,为什么这个 URL 不验证用户的电子邮件,然后使用继续 URL(和关联的域)来触发应用程序打开?它只会触发应用程序打开,而不验证用户的电子邮件。
感谢您提供的任何提示,以帮助我理解我不理解的内容:)
【问题讨论】:
标签: firebase firebase-dynamic-links ios-universal-links email-verification