ios - React Native [[DEFAULT]] firebaseapp 未初始化react-native-firebase

标签 ios reactjs firebase react-native react-redux

我正在尝试将react-native-firebase模块与react native一起使用。

我收到错误:

enter image description here

我遵循的步骤:

第1步:创建基本应用

react-native init myFirebaseApp

移至项目

cd myFirebaseApp

已安装的模块

npm install --save react-native-firebase

第 2 步:设置 Firebase SDK ( https://rnfirebase.io/docs/v4.2.x/installation/ios )

创建了 firebase 应用并下载了适用于 iOS 的 GoogleService-Info.plist

已复制

GoogleService-Info.plist

在项目中,然后

pod init

将这些行添加到 pod 文件

  pod 'Firebase/Core'
  pod 'Firebase/Firestore'

已安装的依赖项

pod install

最后是链接库

react-native link

有人可以指导我遗漏或做错了什么吗?

最佳答案

修改您的 AppDelegate.hAppDelegate.m 文件

AppDelegate.h中添加此内容,

#import <Firebase.h>

并在AppDelegate.m中添加[FIRApp configure];

#import <React/RCTRootView.h>
#import <ReactNativeNavigation/ReactNativeNavigation.h>

@implementation AppDelegate

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure]; // <=== Add this line

  NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];

  return YES;
}

@end

关于ios - React Native [[DEFAULT]] firebaseapp 未初始化react-native-firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50815094/

相关文章:

ios - Firebase 错误 : You must enable this service in the console

ios - 我们可以根据 uiview touch 获取哪个单元格被触摸了吗?

xcode - 无效的权利 iOS SDK 4.1

javascript - 在 React 中更改 radio 输入后,如何从其他嵌套 sibling 中删除类名?

reactjs - 没有 Ice Candidates 聚集,peerConnection.iceGatheringState 立即返回 "complete"

javascript - 将 key 添加到 firestore 文档时出现问题

objective-c - 在运行时更改 iOS 4 中应用程序的图标

javascript - 尝试在我的 React/TypeScript 组件中引用模拟数据对象,同时还将匹配类型导入为 Props

java - Gradle 无法加载 Google playServicesVersion

ios - 为 Firebase 6.5.0 安装 Geofirestore