swift - 我想在一周中的特定日子发送通知
问题描述
我只想在周一、周二、周三、周四和周五上午 11:55 发送本地通知。我找不到详细的来源。你能帮助我吗?
解决方案
您可以使用UNCalendarNotificationTrigger
和创建触发器。您可以设置日期、时区、年、月、日、小时、分钟以及是否需要重复。接下来,创建一个请求UNNotificationRequest
,并完成将请求添加到通知中心。
像这样:
import UserNotifications
let trigger = UNCalendarNotificationTrigger(dateMatching: DateComponents(calendar: Calendar.current, timeZone: Calendar.current.timeZone, year: 2019, month: 1, day: 14, hour: 11, minute: 55, repeats: true )
let request = UNNotificationRequest(identifier: "identifier", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
您只能创建(计划)64 个本地通知
推荐阅读
- azure - 获取数据时出现意外错误代码 13 Spring-Cloud-Stream Kafka Azure 事件中心 -
- c# - Irony BnfExpression 产生不同的非终结符,可以是任何顺序
- python - 仅计算 Pandas 数据系列中的当前行和上一行
- python - 如何在python中迭代文件中的json项目并将其附加到列表中
- graph - 如何找到图形的边界?
- sql - ORA-00904: "FOODSUPPLY"."FOODSUPPLYID": 标识符无效
- android - 服务端数据更新时向 Android 应用发送推送通知,并打开自定义 Activity
- fabric8 - 使用 maven fabric8 插件将多个 docker 图像保存到一个 tar.gz 文件中
- python - Hunk #1 在 53 时失败
- javascript - 如何在 nodejs 的服务器端设置或获取 cookie?