I'm working on an app that gives you a notification at mid-day. This notification is supposed to be different every day.
I got the notifications themselves working:
let notificationOptions: UNAuthorizationOptions = [.alert, .sound]; UNUserNotificationCenter.current().requestAuthorization(options: notificationOptions) { (granted, error) in if !granted { print("Something went wrong") } else { let content = UNMutableNotificationContent() content.body = getRandomDailyString() content.sound = UNNotificationSound.default() let date = DateComponents(hour: 12, minute: 15) let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true) let request = UNNotificationRequest(identifier: "Daily String", content: content, trigger: trigger) UNUserNotificationCenter.current().add(request) { (error) in if let error = error { print(error.localizedDescription) } } } } What's happening now is that the getRandomDailyString()-function is called, it returns a string, and a repeating notification is set which does appear the specified time, but always has the same content.
How would I go about making a notification that gives a unique content every day?
repeats: true, so this notification you created will be shown repeatedly. You should schedule 1 notification at a time.