From the course: iOS and watchOS App Development: Notifications

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Update notification content

Update notification content

From the course: iOS and watchOS App Development: Notifications

Start my 1-month free trial

Update notification content

- [Instructor] Data might change while a request is still pending. To best serve your user, you'll need to update the content. Let's look at how to update content of a pending notification. You'll need to get the notification, then update its content. Delivered and pending notifications return a content object, UNNotificationContent, which is read only, so we'll have to replace the content. I'll set this up to change the content in a notification with a step for making pizzas. Stop the app and head back to View Controller, and head to the top. You'll see I made a global constant of pizza steps, and what we're going to do is change the pizza step by pushing a button in the manage notification View Controller. So, going back to Manage Notification View Controller, and just underneath where it says nextPizzaStep, which is the one we're going to be using, give yourself some space and add the following function, func updatePizzaContent. That will be a request of UNNotificationRequest, and…

Contents