enableBackgroundLocation method

Future<void> enableBackgroundLocation(
  1. int id,
  2. BackgroundNotification bgNotification
)

开启后台定位

Implementation

Future<void> enableBackgroundLocation(
  int id,
  BackgroundNotification bgNotification,
) {
  return platform(
    android: (pool) async {
      final notification = await android_app_Notification.create(
        contentTitle: bgNotification.contentTitle,
        contentText: bgNotification.contentText,
        when: bgNotification.when,
        channelId: bgNotification.channelId,
        channelName: bgNotification.channelName,
        enableLights: bgNotification.enableLights,
        showBadge: bgNotification.showBadge,
      );
      await checkClient();
      await _androidClient?.enableBackgroundLocation(id, notification);
      pool..add(notification);
    },
    ios: (pool) async {
      await _iosClient?.set_allowsBackgroundLocationUpdates(true);
      await _iosClient?.set_pausesLocationUpdatesAutomatically(false);
    },
  );
}