testing repeating notification

This commit is contained in:
BroodjeAap 2020-12-01 17:19:03 +01:00
parent 949c1300e6
commit 82335d1025

View file

@ -38,6 +38,12 @@ class _NotificationPageState extends State<NotificationsPage> {
textColor: Colors.white,
onPressed: _scheduleNotify
),
FlatButton(
child: Text("Repeat!"),
color: Colors.blue,
textColor: Colors.white,
onPressed: _repeatNotification
),
FlatButton(
child: Text("Waiting?"),
color: Colors.blue,
@ -107,6 +113,20 @@ class _NotificationPageState extends State<NotificationsPage> {
);
}
Future<void> _repeatNotification() async {
const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails(
'id',
'name',
'desc'
);
const NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.periodicallyShow(0, 'repeating title',
'repeating body', RepeatInterval.hourly, platformChannelSpecifics,
androidAllowWhileIdle: true);
}
Future<void> _cancelAllNotifications() async {
await flutterLocalNotificationsPlugin.cancelAll();
}