反应原生的Firebase身份验证错误?

时间:2018-01-02 21:30:41

标签: firebase react-native firebase-authentication

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"   属性"

有谁知道为什么会这样?

1 个答案:

答案 0 :(得分:0)

如果您已正确设置应用程序,则无需执行第二次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,
};