showLiveActivity method

  1. @override
Future<bool> showLiveActivity({
  1. required int id,
  2. required String channelId,
  3. required String channelName,
  4. String? title,
  5. String? body,
  6. String? subText,
  7. int? progress,
  8. bool indeterminate = false,
  9. bool ongoing = true,
  10. String? payload,
})
override

Post or update an Android live ongoing notification (the Android equivalent of an iOS Live Activity). Uses a promoted Live Update (ProgressStyle) on Android 16+, a normal ongoing notification with a progress bar otherwise. Returns true if shown.

Implementation

@override
Future<bool> showLiveActivity({
  required int id,
  required String channelId,
  required String channelName,
  String? title,
  String? body,
  String? subText,
  int? progress,
  bool indeterminate = false,
  bool ongoing = true,
  String? payload,
}) async {
  try {
    final ok = await methodChannel.invokeMethod<bool>('showLiveActivity', {
      'id': id,
      'channelId': channelId,
      'channelName': channelName,
      'title': title,
      'body': body,
      'subText': subText,
      'progress': progress,
      'indeterminate': indeterminate,
      'ongoing': ongoing,
      'payload': payload,
    });
    return ok ?? false;
  } catch (_) {
    return false;
  }
}