远程配置 iOS API

开启本地调试状态

用于开发阶段在本地测试远程配置参数,Bugtags SDK 会自动读取 mainBundle 里的 main.local.plist 文件并执行,不会读取缓存在本地的远程配置数据,也不会获取云端的远程配置数据,建议在 DEBUG 时设置

Objective-C

BugtagsOptions *options = [[BugtagsOptions alloc] init];
options.remoteConfigDataMode = BTGDataModeLocal;
[Bugtags startWithAppKey:@"APP_KEY" invocationEvent:BTGInvocationEventBubble options:options];

Swift 3

let options = BugtagsOptions()
options.remoteConfigDataMode = BTGDataModeLocal
Bugtags.start(withAppKey: "APP_KEY", invocationEvent: BTGInvocationEventBubble, options: options)

Swift 2

let options = BugtagsOptions()
options.remoteConfigDataMode = BTGDataModeLocal
Bugtags.startWithAppKey("APP_KEY", invocationEvent: BTGInvocationEventBubble, options: options)

开启测试状态

请确保待测试参数已经同步到测试环境,建议在 DEBUG 时设置

Objective-C

BugtagsOptions *options = [[BugtagsOptions alloc] init];
options.remoteConfigDataMode = BTGDataModeTesting;
[Bugtags startWithAppKey:@"APP_KEY" invocationEvent:BTGInvocationEventBubble options:options];

Swift 3

let options = BugtagsOptions()
options.remoteConfigDataMode = BTGDataModeTesting
Bugtags.start(withAppKey: "APP_KEY", invocationEvent: BTGInvocationEventBubble, options: options)

Swift 2

let options = BugtagsOptions()
options.remoteConfigDataMode = BTGDataModeTesting
Bugtags.startWithAppKey("APP_KEY", invocationEvent: BTGInvocationEventBubble, options: options)

获取参数下发值

Objective-C

  • 获取布尔值

      [[Bugtags remoteConfig] boolForKey:@"PARAM_KEY"];
    
  • 获取整型值

      [[Bugtags remoteConfig] integerForKey:@"PARAM_KEY"];
    
  • 获取字符串值

      [[Bugtags remoteConfig] stringForKey:@"PARAM_KEY"];
    

Swift 3

  • 获取布尔值

      Bugtags.remoteConfig().bool(forKey: "PARAM_KEY")
    
  • 获取整型值

      Bugtags.remoteConfig().integer(forKey: "PARAM_KEY")
    
  • 获取字符串值

      Bugtags.remoteConfig().string(forKey: "PARAM_KEY")
    

Swift 2

  • 获取布尔值

      Bugtags.remoteConfig().boolForKey("PARAM_KEY")
    
  • 获取整型值

      Bugtags.remoteConfig().integerForKey("PARAM_KEY")
    
  • 获取字符串值

      Bugtags.remoteConfig().stringForKey("PARAM_KEY")
    

同步远程配置

通常情况下,Bugtags SDK 会在初始化阶段自动同步远程配置,如果需要手动同步远程配置,可调用:

Objective-C

[Bugtags sync];

Swift

Bugtags.sync()
评论