RNFirebase 电子邮件验证

Jam*_*hew 2 firebase react-native firebase-authentication react-native-firebase

我正在尝试向从我的应用程序注册的用户发送电子邮件,但我得到auth/internal-error了回应。有人可以帮我解决这个问题吗???

          var currentUser = firebase.auth().currentUser;
          var actionCodeSettings = {
            url: WEBSITE,
            iOS: {
              bundleId: getBundleIdentifier()
            },
            android: {
              packageName: getBundleIdentifier(),
              installApp: false,
              minimumVersion: '1'
            },
            handleCodeInApp: false,
            dynamicLinkDomain: getDynamicLink()
          };
          currentUser.sendEmailVerification(actionCodeSettings).then(function () {
            console.log('email sent');
          }, function (error) {
            console.log('email not sent ' + error);
          });
Run Code Online (Sandbox Code Playgroud)

这是我用来向注册或登录用户发送电子邮件的代码,下面是我记录的控制台错误

Error: An internal error has occurred, please try again.
    at createErrorFromErrorData (NativeModules.js:155)
    at NativeModules.js:104
    at MessageQueue.__invokeCallback (MessageQueue.js:414)
    at MessageQueue.js:127
    at MessageQueue.__guard (MessageQueue.js:314)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126)
    at debuggerWorker.js:80
Run Code Online (Sandbox Code Playgroud)

详细错误说明:

code: "auth/internal-error"
domain: "FIRAuthErrorDomain"
framesToPop: 1
nativeStackIOS: (15) ["0   [PROJECT_ID]                    0x000000010570380c RCTJSErrorFromCodeMessageAndNSError + 156", "1   [PROJECT_ID]                    0x00000001… processMethodSignature]_block_invoke_2.129 + 176", "2   [PROJECT_ID]                    0x00000001…baseAuth promiseRejectAuthException:error:] + 292", "3   [PROJECT_ID]                     0x00000001…odeSettings:resolver:rejecter:]_block_invoke + 92", "4   [PROJECT_ID]                    0x00000001…904 __callInMainThreadWithError_block_invoke + 56", "5   libdispatch.dylib                   0x00000001…658 721C34EF-4ABD-395F-8285-FECAA2457BA3 + 370264", "6   libdispatch.dylib                   0x00000001…1cc 721C34EF-4ABD-395F-8285-FECAA2457BA3 + 373196", "7   libdispatch.dylib                   0x00000001…3290 721C34EF-4ABD-395F-8285-FECAA2457BA3 + 53904", "8   CoreFoundation                      0x00000001…c74 6E8ED431-E507-3897-BF3A-AFD3D4C2C49F + 691316", "9   CoreFoundation                      0x00000001…c68 6E8ED431-E507-3897-BF3A-AFD3D4C2C49F + 670824", "10  CoreFoundation                      0x00000001aac6b16c CFRunLoopRunSpecific + 464", "11  GraphicsServices                    0x00000001b4aa3328 GSEventRunModal + 104", "12  UIKitCore                           0x00000001aecd5d0c UIApplicationMain + 1936", "13  [PROJECT_ID]                    0x0000000104a90e5c main + 124", "14  libdyld.dylib                       0x00000001…f6424 8F3A474D-45CC-3991-829F-77B3B151BA86 + 5156"]
userInfo: {FIRAuthErrorUserInfoNameKey: "ERROR_INTERNAL_ERROR", NSLocalizedDescription: "An internal error has occurred, print and inspect the error details for more information.", NSUnderlyingError: {…}}
message: "An internal error has occurred, please try again."
stack: "Error: An internal error has occurred, please try again.?    at createErrorFromErrorData (blob:http://localhost:8081/c7064c8e-a43f-4040-a949-22732e1989f3:2126:17)?    at blob:http://localhost:8081/c7064c8e-a43f-4040-a949-22732e1989f3:2078:27?    at MessageQueue.__invokeCallback (blob:http://localhost:8081/c7064c8e-a43f-4040-a949-22732e1989f3:2645:18)?    at blob:http://localhost:8081/c7064c8e-a43f-4040-a949-22732e1989f3:2376:18?    at MessageQueue.__guard (blob:http://localhost:8081/c7064c8e-a43f-4040-a949-22732e1989f3:2549:13)?    at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/c7064c8e-a43f-4040-a949-22732e1989f3:2375:14)?    at http://localhost:8081/debugger-ui/debuggerWorker.js:80:58"
__proto__: Object
Run Code Online (Sandbox Code Playgroud)

Kri*_*yas 5

考虑一下:

  • 您只能向使用电子邮件和密码方法创建的用户发送电子邮件验证 createUserWithEmailAndPassword
  • 成功签名后,Firebase 将返回 auth 对象的承诺。
  • onAuth方法已更改为onAuthStateChanged

检查电子邮件是否已验证:

firebase.auth().onAuthStateChanged(function(user) { 
   if (user.emailVerified) {
       user.sendEmailVerification();
   }
   else {
      console.log('Not verified');
   }
});
Run Code Online (Sandbox Code Playgroud)