Umut Can Alparslan
Umut Can Alparslan

Reputation: 65

I want to send a notification on specific days of the week

I just want to send a local notification at 11:55 am Monday, Tuesday, Wednesday, Thursday and Friday. I couldn't find a detailed source. Can you help me?

Upvotes: 0

Views: 306

Answers (1)

Lailan Matos
Lailan Matos

Reputation: 133

You can use UNCalendarNotificationTrigger and create a trigger. You can set date, timezone, year, month, day, hour, minute and if need repeat or not. Next, create a request UNNotificationRequest, and finish adding the request to Notification Center.

Like this:

import UserNotifications

let trigger = UNCalendarNotificationTrigger(dateMatching: DateComponents(calendar: Calendar.current, timeZone: Calendar.current.timeZone, year: 2019, month: 1, day: 14, hour: 11, minute: 55, repeats: true )
            let request = UNNotificationRequest(identifier: "identifier", content: content, trigger: trigger)
            UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)

You can create (schedule) only 64 local notifications

Upvotes: 0

Related Questions