如何将react-native-firebase添加到现有的react-native应用程序?

时间:2019-09-12 12:41:29

标签: react-native react-native-firebase pod

我正在尝试使用带有现有react-native应用程序的react-native-firebase添加数据库。我的package.json依赖项包括react-native-firebase和react-native-cli。但是,当我运行expo start并使用在iOS模拟器上运行工具时,它会返回错误消息:在iOS上本地找不到RNFirebase核心模块,请确保已在项目“ Podfile”中正确包含RNFirebase Pod,并已运行“ pod install” '。

我已经尝试通过一些教程来运行,但是都没有解决我的问题。

 "dependencies": {
        "@expo/samples": "~3.0.3",
        `enter code here`"@expo/vector-icons": "^10.0.3",
    "@react-navigation/web": "^1.0.0-alpha.9",
    "expo": "^34.0.1",
    "expo-asset": "^6.0.0",
    "expo-constants": "6.0.0",
    "expo-font": "^6.0.1",
    "expo-web-browser": "6.0.0",
    "fb-watchman": "^2.0.0",
    "moment": "^2.24.0",
    "mongodb-stitch-react-native-sdk": "^4.5.0",
    "react": "16.8.3",
    "react-dom": "^16.8.6",
    "react-native": "https://github.com/expo/react- 
    native/archive/sdk-34.0.0.tar.gz",
    "react-native-card-flip": "^1.0.4",
    "react-native-cardview": "^2.0.3",
    "react-native-cli": "^2.0.1",
    "react-native-confetti": "^0.1.0",
    "react-native-firebase": "^5.5.6",
    "react-native-gesture-handler": "~1.3.0",
};


    import { AppLoading } from 'expo';
    import firebase from 'react-native-firebase'
    import { Asset } from 'expo-asset';
    import * as Font from 'expo-font';
    import React, { useState, useEffect } from 'react';
    import { Platform, StatusBar, StyleSheet, View } from 'react- 
    native';
    import { Ionicons } from '@expo/vector-icons';
    import venues from './components/venueJSON';

    import AppNavigator from './navigation/AppNavigator';



    export default function App(props) {
      // react hooks
      const [isLoadingComplete, setLoadingComplete] = 
     useState(false);

     useEffect(() => {
        // Your web app's Firebase configuration
        var firebaseConfig = {
          apiKey: "AIzaSyAHhnWeyBtUHJTtigUNMwQv5naDfNwqoOQ",
          authDomain: "musability-91b3d.firebaseapp.com",
          databaseURL: "https://musability-91b3d.firebaseio.com",
          projectId: "musability-91b3d",
          storageBucket: "",
          messagingSenderId: "168169604472",
          appId: "1:168169604472:web:32bccbafe468799ff2b48d"
        };



    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);

    console.log(firebase);  
  })

我想为iOS和android安装正确的模块,并能够连接到数据库并在两个平台上查看它。

1 个答案:

答案 0 :(得分:0)

您应该为每个平台安装react-native-firebase本机。

对于iOS-https://rnfirebase.io/docs/v5.x.x/installation/ios

对于Android,请遵循以下步骤-https://rnfirebase.io/docs/v5.x.x/installation/android