【问题标题】:I am trying to add firebase email varification link varification to my app but getting error "can not read email propperty of null"我正在尝试将 Firebase 电子邮件验证链接验证添加到我的应用程序,但出现错误“无法读取 null 的电子邮件属性”
【发布时间】:2019-06-28 09:24:05
【问题描述】:

我正在尝试向我的应用添加 Firebase 电子邮件验证链接验证,但收到错误 cannot read email property of null

我尝试关注 web 的 firebase 文档,但无法找到完整的解决方案,具体在哪里以及如何实施

 var actionCodeSettings = {
  url: 'campatron.com' + firebase.auth().currentUser.email,
  handleCodeInApp: true,
  // When multiple custom dynamic link domains are defined, specify which
  // one to use.
  dynamicLinkDomain: "example.page.link"
};
firebase.auth().currentUser.sendEmailVerification(actionCodeSettings)
  .then(function() {
    // Verification email sent.
  })
  .catch(function(error) {
    // Error occurred. Inspect error.code.
  });

【问题讨论】:

标签: reactjs firebase redux


【解决方案1】:

currentUser 属性尚未初始化,这意味着当您到达此代码时您的用户尚未登录。这段代码在您的应用程序中的哪里调用?

【讨论】:

  • 每当此脚本被导入时,您都会进行此调用 var actionCodeSettings = { url: 'campatron.com' + firebase.auth().currentUser.email, handleCodeInApp: true, // 当多个自定义动态链接定义域,指定使用哪个 // 一个。动态链接域:“example.page.link”}; firebase.auth().currentUser.sendEmailVerification(actionCodeSettings) 这意味着当您导入文件时,您会直接尝试获取用户电子邮件,尝试将其放入函数中并在必要时调用它
  • 谢谢,Milenko 将此代码放入函数中对我有用 :)
猜你喜欢
  • 2019-07-02
  • 2019-05-20
  • 1970-01-01
  • 2021-09-21
  • 1970-01-01
  • 1970-01-01
  • 2017-05-30
  • 2020-07-16
相关资源
最近更新 更多