简体   繁体   English

React-Native:Firebase 错误:No Firebase App [DEFAULT] 已创建 - 调用 Firebase App.initializeApp()(app/no-app)

[英]React-Native: Firebase Error: No Firebase App [DEFAULT] has been created - call Firebase App.initializeApp() (app/no-app)

I am getting this error when I was trying to connect firebase with my React Native App.当我尝试将 firebase 与我的 React Native 应用程序连接时出现此错误。

Firebase Error: No Firebase App [DEFAULT] has been created - call Firebase App.initializeApp() (app/no-app) Firebase 错误:没有创建 Firebase App [DEFAULT] - 调用 Firebase App.initializeApp() (app/no-app)

I have added my code here-我在这里添加了我的代码-

    import { initializeApp } from "firebase/app";
    import { getAuth } from "firebase/auth";
    import { getFirestore } from "firebase/firestore";

   // Your web app's Firebase configuration
const RNfirebaseConfig = {
  apiKey: "........",
  authDomain: "note-app-rn.firebaseapp.com",
  projectId: "note-app-rn",
  storageBucket: "note-app-rn.appspot.com",
  messagingSenderId: ".....",
  appId: "......"
};

const app = initializeApp(RNfirebaseConfig);
export const auth = getAuth(app);
export const db = getFirestore(app);

try this,尝试这个,

import firebase from '@react-native-firebase/app';
import '@react-native-firebase/auth';
import '@react-native-firebase/firestore';

const RNfirebaseConfig = {
  apiKey: "........",
  authDomain: "note-app-rn.firebaseapp.com",
  projectId: "note-app-rn",
  storageBucket: "note-app-rn.appspot.com",
  messagingSenderId: ".....",
  appId: "......"
};

let app;
if (firebase.apps.length === 0) {
    app = firebase.initializeApp(RNfirebaseConfig )
} else {
    app = firebase.app()
}

const db = firebase.firestore();
const auth = firebase.auth();

The main source of the error is related to initialize config setting.错误的主要来源与初始化配置设置有关。

Checkout this usage;检查这个用法;

import firebase from 'firebase/compat/app'
import 'firebase/compat/auth'
import 'firebase/compat/firestore'

export const firebaseConfig = {
    apiKey: "............",
    authDomain: "............",
    projectId: "............",
    storageBucket: "............",
    messagingSenderId: "............",
    appId: "............",
    measurementId: "............"
}

if (!firebase.apps.length){
    firebase.initializeApp(firebaseConfig);
} 

Did it happen during migration to new React Native architecture?它是在迁移到新的React Native架构期间发生的吗?

Remember to change your import:请记住更改您的导入:

  • from: @import Firebase;来自: @import Firebase; in AppDelegate.mAppDelegate.m
  • to: #import <Firebase.h> in AppDelegate.mm到: #import <Firebase.h>AppDelegate.mm

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 firebase.firestore with react 没有创建 Firebase App &#39;[DEFAULT]&#39; - 调用 Firebase App.initializeApp() (app/no-app) - firebase.firestore with react No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app) 未捕获的 FirebaseError:Firebase:否 Firebase 应用程序“[DEFAULT]”已创建 - 调用 Firebase App.initializeApp() - 在 React.js 中 - Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app). - In React.js 故障:Firebase:没有 Firebase App '[DEFAULT]' 已创建 - 调用 Firebase App.initializeApp() (app-com) - Trouble: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app-compat/no-app) 如何解决 Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app) - How to solve Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app) Firebase:未创建Firebase应用程序&#39;[DEFAULT]&#39;-调用Firebase App.initializeApp() - Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() "Firebase 错误:未创建 Firebase 应用默认值" - Firebase error: No firebase app default has been created 获取 Firebase: No Firebase App '[DEFAULT]' has been created 错误 - Getting Firebase: No Firebase App '[DEFAULT]' has been created error app.initializeApp 在使用 Firebase Class 时不是 function - app.initializeApp is not a function when using Firebase Class 如何解决反应中的以下错误 - ' Firebase: No Firebase App '[DEFAULT]' has been created '? - How to solve the following error in react - ' Firebase: No Firebase App '[DEFAULT]' has been created '? React Firebase Auth 初始化问题 - 没有创建 Firebase App '[DEFAULT]' - React Firebase Auth initialization problem - No Firebase App '[DEFAULT]' has been created
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM