Home > OS >  Flutter Notifications after one hour
Flutter Notifications after one hour

Time:10-03

Hello I need to make local notification on mobile whenever a button is pressed. And i don't want to make the notification instantly but after one hour when the user hit that button does anyone have any idea?

I tried this plugin flutter_local_notifications: ^8.2.0

But can some help me how to do the trigger after one hour

Thanks

CodePudding user response:

Use this function to call notifications every hour

 shownotifications() async {

const AndroidNotificationDetails androidPlatformChannelSpecifics =
    AndroidNotificationDetails('repeating channel id',
        'repeating channel name', 'repeating description');
const NotificationDetails platformChannelSpecifics =
    NotificationDetails(android: androidPlatformChannelSpecifics);
await FlutterLocalNotificationsPlugin().periodicallyShow(0, 'Test title',
    'test body', RepeatInterval.hourly, platformChannelSpecifics,
    androidAllowWhileIdle: true);
 }

and follow this article step by step to to setup the package you are using

  • Related