1
在我的应用程序中,我想添加本地通知。该场景将是用户可以选择从Mon到Sun的任何时间和日期。例如,如果用户选择星期一,星期四和星期六为下午11点的日期和时间,那么现在应在所有选定日期和特定时间通知用户。迅速设置特定日期和时间的本地通知3
代码:
let notification = UNMutableNotificationContent()
notification.title = "Danger Will Robinson"
notification.subtitle = "Something This Way Comes"
notification.body = "I need to tell you something, but first read this."
let notificationTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
// let test = UNCalendarNotificationTrigger()
let request = UNNotificationRequest(identifier: "notification1", content: notification, trigger: notificationTrigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
我使用此代码,但这并不根据我所需要的工作。
您在此代码中的timeInterval是60秒。所以,它会在60秒后开火。你没有实施任何在多天内触发它的逻辑? –
类似于https://stackoverflow.com/questions/41800189/local-notifications-repeat-interval-in-swift-3看起来很有趣 – MadProgrammer