Basically, I need an app that runs a notification every other Monday. What I have is an app that runs a notification every Monday. Is there a way to set it up so that when the first notification is received the app will begin a two week time interval where it will run the notification again, and have it repeat? For example, if I had a variable called "week" and had it alternate between '1' and '2' every other week, how could I tag it to the notification's trigger?
func notification(hour: Int, minute: Int, weekday: Int, text: String){
let content = UNMutableNotificationContent()
content.title = "Example"
content.body = text
content.sound = UNNotificationSound.default()
let trigger = UNCalendarNotificationTrigger(dateMatching: DateComponents(hour: hour, minute: minute, weekday: weekday), repeats: true)
let request = UNNotificationRequest(identifier: text, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
notification(hour: 12, minute: 0, weekday: 2, text: "Test")
}