问题
I want a notification to show every 60 seconds. It only happened once on MacOS. The same exact code works normally on iOS.
If I manually remove the notification from macOS notification center, it'll eventually show again. So the problem seems like notification won't show again if it's already showed once and the user didn't take any action.
Did I miss something obvious here?
Current macOS: 10.15.4 Current iOS: 13.4.1
on App Delegate
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .badge, .sound])
}
on DidLaunch equivalent (iOS and macOS)
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.alert, .sound, .badge]) { (grant, err) in
if grant {
let content = UNMutableNotificationContent()
content.title = "AY"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
let req = UNNotificationRequest(identifier: "ay", content: content, trigger: trigger)
center.add(req)
}
}
来源:https://stackoverflow.com/questions/61872174/untimeintervalnotificationtrigger-repeats-true-only-fired-once-macos-bug-wo