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.
Code the notification extension
From the course: iOS and watchOS App Development: Notifications
Code the notification extension
- [Instructor] Where you customize your push notifications content is the notificationservice.swift file. If not already open, go ahead and open it, you'll find it in the service extension of course. This is only two functions and two properties. There's a property that's important called the bestAttemptContent that you'll find all the way up here at the top, which is a mutable copy of your push notifications content. The core function is the didRecieve request with content handler. In this method, you modified the content for the push notification. Notice on the bottom of the method, the call to the closure must be there for this to work. The template currently changes the title. I can change that to Push, so I know what is a push notification. Let's add some code, so the remote and snooze local notifications look the same. To keep it simple, I'm going to copy and paste the change pizza notification function and the surfer bullet in the delegate to the notification service. So I'm…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.