У меня есть UNUserNotificationCenter, который отправляет локальное уведомление каждые 60 секунд. Это реализовано, как показано ниже:
let userNotificationCenter = UNUserNotificationCenter.current()
let notificationContent = UNMutableNotificationContent()
notificationContent.title = "Test title"
notificationContent.body = "Test body"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60,
repeats: true)
let request = UNNotificationRequest(identifier: "testNotification",
content: notificationContent,
trigger: trigger)
userNotificationCenter.add(request) { (error) in
if let error = error {
print("Notification Error: ", error)
}
}
Работает хорошо, но я не могу это остановить и продолжает отправлять уведомления, даже если мое приложение убито.
Каков наилучший способ остановить UNUserNotificationCenter для отправки уведомлений в этом случае?