我希望每月向用户显示一次对话消息。如果用户关闭该消息,那么我将重新启动计时器并在 30 天后显示它。
我查看了各种软件包,例如为我的应用评分,它跟踪最少天数,但这仅适用于应用评分,而不适用于通用对话框消息。
我希望该对话框在首次启动时显示,然后在消息被取消后每 30 天显示一次。
从 DateTime 类开始捕获对话框显示的时间
var now = new DateTime.now();
您可以使用具有调度功能的flutter_local_notifications。
var scheduledNotificationDateTime =
new DateTime.now().add(new Duration(days: 30));
var androidPlatformChannelSpecifics =
new AndroidNotificationDetails('your other channel id',
'your other channel name', 'your other channel description');
var iOSPlatformChannelSpecifics =
new IOSNotificationDetails();
NotificationDetails platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.schedule(
0,
'scheduled title',
'scheduled body',
scheduledNotificationDateTime,
platformChannelSpecifics);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句