react-native - 如何将 react-native-firebase 添加到现有的 react-native 应用程序?
问题描述
我正在尝试使用 react-native-firebase 和现有的 react-native 应用程序添加数据库。我的 package.json 依赖项包括 react-native-firebase 和 react-native-cli。但是,当我运行 expo start 并使用在 iOS 模拟器工具上运行时,它返回错误消息:RNFirebase core modules was not found native on iOS,请确保您已将 RNFirebase pod 正确包含在项目“Podfile”中并运行“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 安装正确的模块,并能够连接到数据库并在两个平台上查看它。
解决方案
react-native-firebase
您应该为每个平台安装本机。
对于 iOS - https://rnfirebase.io/docs/v5.xx/installation/ios
对于 Android,请遵循此 - https://rnfirebase.io/docs/v5.xx/installation/android
推荐阅读
- sql - 如何修复外键约束
- java - 显示字符串没有第 6 个字符时出现问题
- python - Keras 中的 waveGAN - 卷积网络层中的维度
- javascript - html 中的 NaN 输出,但控制台上显示正确的输出
- docker - docker - 永久存储 docker-credential-helpers 凭据
- mysql - MySQL Explain 根据条件值更改计划
- xml - XQuery 关键字搜索问题
- c - 尝试在一行中对多个值(3 个字符串 + 整数)进行 fscanf
- python - 表函数导致 R 在 Python 熊猫中具有三个变量
- leaflet - 如何将传单地图插件添加到ionic4代码?