enableForeground method

Future<void> enableForeground({
  1. required int notificationId,
  2. required String channelId,
  3. required String title,
  4. required String text,
  5. String? smallIconResourceName,
})

启用前台定位服务,让定位在应用进入后台时也能继续运行。

Platforms:

  • 🅰️ Android:支持
  • 🍏 iOS:不支持,抛出 TencentLocationError(错误码 unsupportedOnThisPlatform
  • 🔶 Harmony:不支持,抛出 TencentLocationError(错误码 unsupportedOnThisPlatform

Parameters:

  • notificationId:前台通知的唯一 ID,必须大于 0。
  • channelId:Android O(API 26)及以上版本必填的 NotificationChannel ID。
  • title:通知栏展示的标题文案。
  • text:通知栏展示的正文文案。
  • smallIconResourceName:通知小图标的资源名(位于 mipmap / drawable 下,不含扩展名);为空时使用应用默认图标。

Implementation

Future<void> enableForeground({
  required int notificationId,
  required String channelId,
  required String title,
  required String text,
  String? smallIconResourceName,
}) =>
    _after(() => _platform.enableForeground(
          managerId: _id,
          notificationId: notificationId,
          channelId: channelId,
          title: title,
          text: text,
          smallIconResourceName: smallIconResourceName,
        ));