【问题标题】:Firebase not sending sendPasswordReset emailFirebase 不发送 sendPasswordReset 电子邮件
【发布时间】:2021-06-27 02:26:22
【问题描述】:

我一直在尝试让 Firebase 使用以下代码发送密码重置电子邮件:

let email = "myemailaddress@gmail.com"

@IBAction func changePasswordTapped(_ sender: Any) {
                    
       Auth.auth().sendPasswordReset(withEmail: self.email) { (error) in
           print(self.email)
       }
    }

控制台根据print(self.email)打印出我的电子邮件地址,但经过多次尝试并等待超过一天后,我没有收到任何电子邮件。我检查了所有的电子邮件文件夹,包括垃圾邮件。

还有什么其他需要实现的吗?

非常感谢任何帮助/指导!

【问题讨论】:

  • 这能回答你的问题吗? Firebase Reset Password Swift
  • 好吧,你没有检查是否有错误,所以代码只会默默地失败,你不会知道为什么。您应该在闭包中添加错误处理,例如if let err == error { print(err.localizedDescription) },并查看它是否打印和错误。然后'你会知道问题是什么。
  • 谢谢@Jay!这帮助我更深入地挖掘。对电子邮件地址进行硬编码无法作为测试,因为 Firebase 无法将其与用户关联。因此,只需将电子邮件设置为 let email = Auth.auth().currentUser?.email 即可。

标签: ios swift firebase firebase-authentication passwords


【解决方案1】:

Firebase 不允许我对电子邮件地址进行硬编码。我收到了这个错误:

There is no user record corresponding to this identifier. The user may have been deleted.

一旦我将电子邮件地址设置为 currentUser,它就起作用了:

let email = Auth.auth().currentUser?.email

@IBAction func changePasswordTapped(_ sender: Any) {
                    
       Auth.auth().sendPasswordReset(withEmail: self.email) { (error) in
           print(self.email)
       }
    }

【讨论】:

    猜你喜欢
    • 2022-11-20
    • 1970-01-01
    • 2018-11-21
    • 2011-09-16
    • 2015-08-13
    • 2019-06-24
    • 2016-09-22
    • 2018-11-08
    • 1970-01-01
    相关资源
    最近更新 更多