问题描述
我每天都尝试使用插件flutter_local_notifications 向用户发送定期通知,但是该插件可用的资源仅包含代码,并且难以理解,我已经完成了该插件的设置,如下:
- 添加了flutter_local_notifications 的依赖项
- 在
AppDelegate.swift
中添加了iOS的权限代码
我通过引用medium等众多资源和其他一些网站来做很多事情,所以有人可以写一种每天向用户(Android和iOS)发送定期通知的方法吗?谢谢!
解决方法
写完该评论后,我做了一些研究,到目前为止对我来说是有效的:
Future<void> showAlertNotification() async {
var time = Time(8,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'));
}