当您只有一个目标时,Firebase 建议使用它来支持多个环境。不过这是在 swift 上,因为 react-native 中的 appledelegate.m 不使用 swift,它在 objective c 上会是什么。
let filePath = Bundle.main.path(forResource: "MyGoogleService", ofType: "plist")
guard let fileopts = FIROptions.init(contentsOfFile: filePath)
else { assert(false, "Couldn't load config file") }
FIRApp.configure(with: fileopts)
最佳答案
在 Objective-C 中你可以这样写。
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyGoogleService" ofType:@"plist"];
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
[FIRApp configureWithOptions:options];
关于ios - firebase 中的 swift 代码等效于 objective c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42592815/