每日定期通知扑朔迷离

时间:2020-09-03 12:14:36

标签: flutter dart push-notification hybrid-mobile-app

我每天都尝试使用插件flutter_local_notifications 向用户发送定期通知,但是该插件可用的资源仅包含代码,并且难以理解,我已经完成了该插件的设置,如下:

我通过引用medium等众多资源和其他一些网站来做很多事情,所以有人可以写一种每天向用户(Android和iOS)发送定期通知的方法吗?谢谢!

1 个答案:

答案 0 :(得分:1)

写完该评论后,我做了一些研究,到目前为止对我来说是有效的:

Future<void> showAlertNotification() async {
    var time = Time(8, 0, 0);
    var androidChannel = AndroidNotificationDetails(
        'channelID', 'channelName', 'channelDescription',
        importance: Importance.defaultImportance,
        priority: Priority.defaultPriority,
        playSound: true);

    var iosChannel = IOSNotificationDetails();
    var platformChannel =
        NotificationDetails(android: androidChannel, iOS: iosChannel);
   await flutterLocalNotificationsPlugin.showDailyAtTime(2, 'notification title',
            'message here', time, platformChannel,
            payload: 'new payload'));
  }