Knowing the process notifications use can give insight into coding notifications. Push notifications are handled differently than local notifications and the developer must code accordingly. In this video, learn how to outline the process an Apple Watch receives a user notification using the commonly used push notification.
- [Instructor] The last major feature of an Apple watch is notifications. Notifications on the watch make it easy to see notifications with a glance at your wrist, instead of grabbing for your phone. User notifications on the watch are very similar to IOS user notifications. For the most part, they use the same framework, user notifications. For that reason I'm going to look more at how they appear on the watch, than how to make a notification. So, take a look at the notifications course in the library for more on making notifications for both phone and watch. User notifications have two flavors. Local notifications and Push. Sometimes called remote notifications. I'll start with the push notifications. Push notifications come from an external server, sending a JSON payload to the watch, like the one you have here under push notification payload, a PNS. Testing push notification functionality, the watch is very easy. We have this test payload in the watch extension and there's a scheme to do it. If you go to the top, you'll see under Hollie Pizza menu watch in the schemas, there's one here that says notification and click on that. Go ahead and run that, and you'll get a message saying, "Would you be willing to take notifications?", and we're going to say, "Allow". We're now authorized for notifications. And we get a notification saying Hello World. You'll notice there's no graphic here. You add those in the watch apps icons folder. And there's two graphics you're going to be adding here. So let's head back over there first. So I'm going to stop this. And you'll find those over here in the watch app under app icon. And you'll see there's the notification center one which is the one we just saw. And we saw it very short timeframe for only like a second or so, the short look, which is the one to go here. Now we get to fill all these in, but that's a pain in the neck to do. So what I'm going to to do is replace them like we did before. So I'm going to do a show in Finder, like that. And I already have available in the exercise files, a version of this. So I'm going to go into here. And here's app icon applications. I'm going to move that one to trash. And I'm going to copy this one, in here. Alright. And now I can go back to my code. And you'll see here, the app icon. They're all in place and we've got all of our surfboards in correctly. So let's go ahead and try that again. And I'm going to go ahead and run let's see what happens. Your first notification is a short look, and then the long look. And we've got our surfboard in both. We'll now look at how this push notification and the local notification can be more customized in the rest of this chapter.