testing repeating notification
This commit is contained in:
parent
949c1300e6
commit
82335d1025
1 changed files with 20 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue