且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Firebase数据库中分离测试和生产数据?

更新时间:2023-11-27 09:50:34

创建多个Firebase项目。每个项目都有自己的plist文件。

Create multiple Firebase projects. Each project has its own plist file.

FIRApp 有一个自定义配置选项。下载测试/调试项目的plist,重命名并加载如下。

FIRApp has a custom configuration option. Download the plist for your testing/debug project, rename it and load like below.

#if DEBUG
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-dev" ofType:@"plist"];
    FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
    [FIRApp configureWithOptions:options];
#else
    [FIRApp configure];
#endif

可以找到更详细的解释这里

A more detailed explanation can be found here