init static method

Future<InitResultInfo> init({
  1. String? androidAppId,
  2. String? iOSAppId,
  3. String? channel,
  4. bool autoCheckUpgrade = true,
  5. bool autoInit = true,
  6. bool autoDownloadOnWifi = false,
  7. bool enableHotfix = false,
  8. bool enableNotification = false,
  9. bool showInterruptedStrategy = true,
  10. bool canShowApkInfo = true,
  11. int initDelay = 0,
  12. int upgradeCheckPeriod = 0,
  13. int checkUpgradeCount = 1,
  14. bool customUpgrade = true,
})

初始化

Implementation

static Future<InitResultInfo> init({
  String? androidAppId,
  String? iOSAppId,
  String? channel, // 自定义渠道标识
  bool autoCheckUpgrade = true,
  bool autoInit = true,
  bool autoDownloadOnWifi = false,
  bool enableHotfix = false,
  bool enableNotification = false, // 未适配 androidx
  bool showInterruptedStrategy = true, // 设置开启显示打断策略
  bool canShowApkInfo = true, // 设置是否显示弹窗中的 apk 信息
  int initDelay = 0, // 延迟初始化,单位秒
  int upgradeCheckPeriod = 0, //升级检查周期设置,单位秒
  int checkUpgradeCount = 1, // UpgradeInfo 为 null 时,再次 check 的次数,经测试 1 为最佳
  bool customUpgrade = true, // 是否自定义升级,这里默认 true 为了兼容老版本
}) async {
  assert(
    (Platform.isAndroid && androidAppId != null) ||
        (Platform.isIOS && iOSAppId != null),
  );
  assert(_postCaught, 'Run postCatchedException first.');
  _channel.setMethodCallHandler(_handleMessages);
  _checkUpgradeCount = checkUpgradeCount;
  Map<String, Object?> map = {
    "appId": Platform.isAndroid ? androidAppId : iOSAppId,
    "channel": channel,
    "autoCheckUpgrade": autoCheckUpgrade,
    "autoDownloadOnWifi": autoDownloadOnWifi,
    "enableHotfix": enableHotfix,
    "enableNotification": enableNotification,
    "showInterruptedStrategy": showInterruptedStrategy,
    "canShowApkInfo": canShowApkInfo,
    "initDelay": initDelay,
    "upgradeCheckPeriod": upgradeCheckPeriod,
    "customUpgrade": customUpgrade,
  };
  final dynamic result = await _channel.invokeMethod('initBugly', map);
  Map resultMap = json.decode(result);
  var resultBean = InitResultInfo.fromJson(resultMap as Map<String, dynamic>);
  return resultBean;
}