ios - react native [[DEFAULT]] firebaseapp 未初始化 react-native-firebase
问题描述
我正在尝试将 react-native-firebase 模块与 react native 一起使用。
我得到的错误:
我遵循的步骤:
Step1:创建基本应用程序
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.h
和AppDelegate.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
推荐阅读
- c# - 如何修复“无效的登录令牌”。尝试将经过身份验证的用户与 AWS 和 Cognito 用户池一起使用时
- visual-studio - Visual Studio 2017 中的 ROOT cern
- javascript - Git 在发出拉取请求时会看到分支中的许多更改
- php - PHP数组:条件和
- android - 以编程方式将位置添加到推文
- vue.js - 具有隐藏/显示面板的灵活布局
- docker - 如何在 Docker 上为 Vue-router 配置 nginx
- three.js - 如何设置初始相机位置(Three.js/VR)?
- python - Anaconda 环境问题
- c - C 编程:复数结构