-1

How do I change this _repeatNotification() method, to repeat every 2 hours?

Future _repeatNotification() async {
    var androidPlatformChannelSpecifics = AndroidNotificationDetails(
        'repeating channel id',
        'repeating channel name',
        'repeating description');
    var iOSPlatformChannelSpecifics = IOSNotificationDetails();
    var platformChannelSpecifics = NotificationDetails(
        androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
    await flutterLocalNotificationsPlugin.periodicallyShow(0, 'repeating title',
        'repeating body', RepeatInterval.EveryMinute, platformChannelSpecifics);
}
Siddharth Mehra
  • 1,691
  • 1
  • 9
  • 32
magestik
  • 1
  • 2
  • you might want to look at `CountdownTimer` see: https://docs.flutter.io/flutter/quiver.async/CountdownTimer-class.html or `Timer` see: https://stackoverflow.com/questions/14946012/how-do-i-run-a-reoccurring-function-in-dart also there is a package https://pub.dartlang.org/packages/countdown – Doc Apr 07 '19 at 11:19

1 Answers1

0

Referring to: https://pub.dartlang.org/documentation/flutter_local_notifications/latest/flutter_local_notifications/FlutterLocalNotificationsPlugin/periodicallyShow.html

This package only offers 4 enums for periodically showing notification.

What you can do is to edit it's source code.

Here: https://github.com/MaikuB/flutter_local_notifications/blob/master/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java#L266

change 60000 * 60 to 60000 * 60 * 2

Remember to keep the backup of your original package.

Mangaldeep Pannu
  • 3,738
  • 2
  • 26
  • 45