ios - 如何在 Flutter 中为 iOS 创建闹钟应用
问题描述
我想要的是设置一个时间并在该特定时间运行后台进程(飞镖),就像任何基本的警报应用程序一样。我搜索了很多,但我找不到任何对 iOS 有用的东西。我需要它在飞镖中,因为我不能使用平台频道。
解决方案
我使用颤振本地通知包找到了解决该问题的方法,您可以在将来安排通知,它将在前台、后台和应用程序终止时工作,因此涵盖所有情况并在我的场景中完美工作。如果您需要为 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);
推荐阅读
- c# - var 关键字可以将变量类型更改为动态吗?
- python - 如何正确安装手电筒?
- http - Flutter 中的 HTTP POST 获取 Cookie
- laravel - 重定向到受中间件 laravel 保护的路由
- angular - 如何在前端的 IIS Windows 身份验证中获取用户名?
- python-3.x - 我需要能够打印出星号模式,要求用户输入行数
- typescript - keyof typeof StaticClass 似乎包括 StaticClass' 类型本身
- flutter - 无法在颤振中检索保存的图像(仅在 iOS 上可重现的问题)
- mongodb - Querying nested object arrays
- php - 从 WordPress 小部件获取数据以修改帖子内容