periodicallyShowWithDuration method

Future<void> periodicallyShowWithDuration(
  1. int id,
  2. String? title,
  3. String? body,
  4. Duration repeatDurationInterval,
  5. NotificationDetails notificationDetails, {
  6. AndroidScheduleMode androidScheduleMode = AndroidScheduleMode.exact,
  7. String? payload,
})

Periodically show a notification using the specified custom duration interval.

For example, specifying a 5 minutes repeat duration interval means the first time the notification will be an 5 minutes after the method has been called and then every 5 minutes after that.

On Android, this will also require additional setup for the app, especially in the app's AndroidManifest.xml file. Please see check the readme for further details.

Implementation

Future<void> periodicallyShowWithDuration(
  int id,
  String? title,
  String? body,
  Duration repeatDurationInterval,
  NotificationDetails notificationDetails, {
  AndroidScheduleMode androidScheduleMode = AndroidScheduleMode.exact,
  String? payload,
}) async {
  if (kIsWeb) {
    return;
  }
  if (defaultTargetPlatform == TargetPlatform.android) {
    await resolvePlatformSpecificImplementation<
            AndroidFlutterLocalNotificationsPlugin>()
        ?.periodicallyShowWithDuration(
            id, title, body, repeatDurationInterval,
            notificationDetails: notificationDetails.android,
            payload: payload,
            scheduleMode: androidScheduleMode);
  } else if (defaultTargetPlatform == TargetPlatform.iOS) {
    await resolvePlatformSpecificImplementation<
            IOSFlutterLocalNotificationsPlugin>()
        ?.periodicallyShowWithDuration(
            id, title, body, repeatDurationInterval,
            notificationDetails: notificationDetails.iOS, payload: payload);
  } else if (defaultTargetPlatform == TargetPlatform.macOS) {
    await resolvePlatformSpecificImplementation<
            MacOSFlutterLocalNotificationsPlugin>()
        ?.periodicallyShowWithDuration(
            id, title, body, repeatDurationInterval,
            notificationDetails: notificationDetails.macOS, payload: payload);
  } else {
    await FlutterLocalNotificationsPlatform.instance
        .periodicallyShowWithDuration(
            id, title, body, repeatDurationInterval);
  }
}