我正在为prod和staging使用一个构建方案(具有两个不同的捆绑包标识符),并且我尝试为每个方案使用一个单独的GoogleService-Info.plist。有没有办法在初始化GCM (和goole登录)时手动选择plist文件使用?或者有没有可能避免使用plist而手动进行设置?
谢谢!
发布于 2016-09-27 21:23:39
@inidona的答案对我很有效。在我把它转换成Swift之后
对于Swift 2.3:
let filePath = NSBundle.mainBundle().pathForResource("GoogleService-Info", ofType: "plist")
let options = FIROptions(contentsOfFile: filePath)
FIRApp.configureWithOptions(options)对于Swift 3.0:
let filePath = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")!
let options = FIROptions(contentsOfFile: filePath)
FIRApp.configure(with: options)对于Swift 4.0:
let filePath = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")!
let options = FirebaseOptions(contentsOfFile: filePath)
FirebaseApp.configure(options: options!)发布于 2016-09-12 21:11:39
我认为您可以使用这种方式动态配置您的GoogleService-Info.plist,并为不同的包标识符使用不同的名称。
再见·安德烈亚斯
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
[FIRApp configureWithOptions:options];发布于 2017-05-07 05:35:29
这就是我的解决方案!
NSString *filePath;
if([self isProduction]){
filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
}else{
filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-Sandbox" ofType:@"plist"];
}
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];
[FIRApp configureWithOptions:options];就是这样!
https://stackoverflow.com/questions/37615405
复制相似问题