Local notifications with variable text

Hi, I did a watchOS lab today where I asked how to create a local notification (which repeats at a regular interval), but I want to change the text so that that the message is relevant "You currently have x number of words to revise".

I have setup the notification in my extension delegate as follows:

notificationCenter = UNUserNotificationCenter.current()
notificationCenter.removeAllPendingNotificationRequests()
let options: UNAuthorizationOptions = [.alert, .sound, .badge]
Code Block
notificationCenter.requestAuthorization(options: options) {
(didAllow, error) in
if !didAllow {
print("User has declined notifications")
}
}
let content = UNMutableNotificationContent()
content.title = "Overdue cards"
content.body = "You have " + String(wordsOverdue) + " words to revise. "
content.sound = UNNotificationSound.default
content.userInfo = ["Overdue": database.getWordsOverdue()]

The Apple engineer suggested I add the last line as the variable number/content. Then he said to use the NotificationController where there is a didReceive method that is called when a notification comes in, and I can update my notification view.

The problem is, didReceive never gets called. When I test my app, it always just sends the original notification that I setup. What do I need to do for notification controller to know when a local notification has come in?

I'm open to alternative solutions, since I just have a single value that needs to be updated.



Local notifications with variable text
 
 
Q