【问题标题】:Firebase authentication error with react native?反应原生的Firebase身份验证错误?
【发布时间】:2018-01-02 21:30:41
【问题描述】:
import React, { Component } from 'react';
import RNFirebase from 'react-native-firebase';


const firebase = RNFirebase.initializeApp({
    apiKey: 'KEY',
    authDomain: 'APPNAME.firebaseapp.com',
    databaseURL: 'https://APPNAME-#####.firebaseio.com/',
    projectId: 'APPNAME-#####'});

export default firebase;

这是我的代码(显然有替换)我已经添加了所需的 pod 和 GoogleService-Info.plist 文件。

我收到了错误

“无法初始化应用程序。FirebaseOptions 丢失或“appID”无效 属性”

有人知道为什么会这样吗?

【问题讨论】:

    标签: firebase react-native firebase-authentication


    【解决方案1】:

    如果您已正确设置应用程序,则无需执行第二次 initializeApp,因为它会自动为您完成。您应该按照documentation 的要求导入firebase 并继续前进。

    如果您尝试进行多次初始化或手动初始化,您需要检查documentation。基本上你的配置是不完整的,因为完整的配置是;

    // pluck values from your `GoogleService-Info.plist` you created on the firebase console
    const iosConfig = {
      clientId: 'x',
      appId: 'x',
      apiKey: 'x',
      databaseURL: 'x',
      storageBucket: 'x',
      messagingSenderId: 'x',
      projectId: 'x',
    
      // enable persistence by adding the below flag
      persistence: true,
    };
    
    // pluck values from your `google-services.json` file you created on the firebase console
    const androidConfig = {
      clientId: 'x',
      appId: 'x',
      apiKey: 'x',
      databaseURL: 'x',
      storageBucket: 'x',
      messagingSenderId: 'x',
      projectId: 'x',
    
      // enable persistence by adding the below flag
      persistence: true,
    };
    

    【讨论】:

      猜你喜欢
      • 2019-02-23
      • 1970-01-01
      • 2017-12-25
      • 1970-01-01
      • 2017-10-11
      • 2021-07-21
      • 1970-01-01
      • 2016-11-28
      • 2018-08-27
      相关资源
      最近更新 更多