From the course: iOS and watchOS App Development: Notifications

Unlock the full course today

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

Dynamic notification content

Dynamic notification content

From the course: iOS and watchOS App Development: Notifications

Start my 1-month free trial

Dynamic notification content

- [Instructor] While we've made a static content, you may need a more flexible dynamic case. You've used UN mutable notification content to configure the notification content. There is also UN notification content, which stores the notification content of a scheduled or delivered notification that we'll talk about later. It is read-only. You only set properties of UN mutable notification content objects. If you want to change your content into notification you cannot change the content directly but must make a new request with new content. To streamline my code for both initial and change notifications, I often make a template function for default content for my application. So let's make a new function and we'll stick it just below make pizza here, called notification content. And I'm going to give it a title for parameter, which will be a string. And I'm going to give it the body, so I have the two things I usually need, and make that a string as well. And that will return a UN…

Contents