等效于 firebase 中的 swift 代码到目标 c

Jan*_*Jan 0 objective-c ios swift react-native

当您只有一个目标时,Firebase 建议使用它来支持多个环境。不过,这是 swift ,因为 react-native 中的 appledelegate.m 不使用 swift ,所以在目标 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)
Run Code Online (Sandbox Code Playgroud)

Nir*_*v D 6

在 Objective-C 中,你可以这样写。

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyGoogleService" ofType:@"plist"];
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
[FIRApp configureWithOptions:options];
Run Code Online (Sandbox Code Playgroud)