我想要的是设置一个时间并在该特定时间运行后台进程(dart),就像任何基本的警报应用程序一样。
我搜索了很多,但找不到任何对 iOS 有用的东西。我需要它在 dart 中,因为我无法使用平台通道。
我找到了解决该问题的方法flutter本地通知包 https://pub.dev/packages/flutter_local_notifications,您可以在将来安排通知,它可以在前台、后台以及应用程序终止时工作,因此涵盖所有情况并在我的场景中完美工作。如果您需要为 IOS 做闹钟或提醒之类的事情,它会为您完成工作。
var scheduledNotificationDateTime =
DateTime.now().add(Duration(seconds: 5));
var androidPlatformChannelSpecifics =
AndroidNotificationDetails('your other channel id',
'your other channel name', 'your other channel description');
var iOSPlatformChannelSpecifics =
IOSNotificationDetails();
NotificationDetails platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.schedule(
0,
'scheduled title',
'scheduled body',
scheduledNotificationDateTime,
platformChannelSpecifics);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)