如何使我的应用每天能够以可自定义的间隔触发本地通知,但只能在分配的时间段内触发,例如:从10:00到20:00 pm?
现在,我仅以自定义间隔实施重复通知:
func beginNotifications(_ config: UserConfig) {
let interval = config.notificationInterval
let center = UNUserNotificationCenter.current()
center.removeAllPendingNotificationRequests()
let content = UNMutableNotificationContent()
content.title = "Content title"
content.subtitle = "Content body"
content.sound = UNNotificationSound.default
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: interval, repeats: true)
let request = UNNotificationRequest(identifier: "notification", content: content, trigger: trigger)
center.add(request)
}
到目前为止,我只想出了解决方案-使用Timer制作两种单独的方法,该方法每天都会启动和停止通知功能,并为该应用启用后台模式。
答案 0 :(得分:0)
如果安排本地推送通知N次(您想要多少次),我想到的是第一个解决方案。您只需要使identifier
唯一即可。
https://docs.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/serve-model-web-api-ml-net
到目前为止,我只想出了解决方案-制作两种独立的方法 使用计时器,它将每天启动和停止通知功能, 并为该应用启用后台模式。
不建议使用imo,如果您按下此按钮,则可能需要与Apple审核小组联系。