I need to repeat local notification
at specific time and specific days like 10:30 AM at sunday and Friday or selected week days (mon and sat).
switch repeatDays {
case .never:
dateComponents = Calendar.current.dateComponents([.hour, .minute], from: date)
flag = false
case .everyDay:
dateComponents = Calendar.current.dateComponents([.hour, .minute], from: date)
case .everyWeek:
dateComponents = Calendar.current.dateComponents([.weekday, .hour, .minute], from: date)
case .everyMonth:
dateComponents = Calendar.current.dateComponents([.day, .hour, .minute], from: date)
case .everyYear:
dateComponents = Calendar.current.dateComponents([.month, .day, .hour, .minute], from: date)
}
let notificationTrigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: flag)
let request = UNNotificationRequest(identifier: uuid, content: content, trigger: notificationTrigger)
let notiCurrent = UNUserNotificationCenter.current()
notiCurrent.add(request) { (error) in
if let error1 = error {
print(error1.localizedDescription)
}
}
But this repeat notification weekly not repeat Sunday
and Wednesday
or some other specific days