Answer the question
In order to leave comments, you need to log in
Swift How to set local notifications every day except today?
How can I make notifications show every day at the specified time, except for today?
There is a code that displays notifications every day at 10:30:
//Center
let center = UNUserNotificationCenter.current()
center.removeAllPendingNotificationRequests()
//Content
let content = UNMutableNotificationContent()
content.title = "Заголовок"
content.body = "Текст"
content.categoryIdentifier = "alarm"
content.sound = UNNotificationSound(named: UNNotificationSoundName(rawValue: "inflicted.mp3"))
content.badge = 1
//Trigger
var dateComponents = DateComponents()
dateComponents.hour = 10
dateComponents.minute = 30
let triggerDate = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: true)
//Set
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: triggerDate)
center.add(request)
Answer the question
In order to leave comments, you need to log in
You need to set notifications manually , no repeater with custom triggers.
Don't forget to limit the number of local notifications.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question