Join Steven Lipton for an in-depth discussion in this video Launch a JSON payload, part of iOS and watchOS App Development: Notifications.
- [Instructor] We're ready to explore JSON payloads. From this point on, if you've not been following along with the exercises and you're downloading an exercise, please refer to the Using Exercise video in the introduction chapter for very important directions. You'll notice in apnstester, there's a selection for JSON. Click the JSON button, and the payload changes to this. For compactness, the wide space is removed. When sending payloads, avoid wide space for they are hard to read this way.
It looks better with a few tabs and new lines. In Xcode, you'll find a file named HuliPizzaPayload.apns I made for you in the project. And I did exactly that, and got all those spaces all straightened up. You'll see that there's one top level key aps. Apple stores this required key your standard notification content. Aps is a dictionary. There's some standard keys within aps.
The three we have in the sample do much of the work. The key alert posts a message in the body of a notification. The key badge sets a number on the icon badge. The sound plays a sound or vibration when the notification appears on the device. Under alert, change the message to I love pizza. Go ahead and copy and paste this code into apnstester.
Add your pem file if you need it, and go ahead and hit TEST. You'll get your notification on your phone. This is, of course, a very simple example. The payload can get more sophisticated. I wanted to show you the structure before we work more with them. Make sure you have at least an aps key in every payload. These payloads should also remain small. They have a 4,096 byte limit, the equivalent of about 5 tweets.
While we'll leave this payload with wide space so we can read it, in general use, avoid wide space to get the most out of that space.
- Requesting user permission
- Static vs. dynamic notification content
- Sending local notifications
- Updating and removing notifications
- Creating custom notifications
- Adding categories and actions to notifications
- Pushing notifications
- Building push notification payloads: alerts and actions
- Adding service and content extensions
- Attaching rich media: images, audio, and video
- Creating watchOS notifications
Skill Level Intermediate
Apple watchOS 4 App Development Essential Trainingwith Steven Lipton3h 10m Intermediate
1. User Permissions
2. Local Notifications
3. Notification Management
4. Interacting with Notifications
5. Push Notifications
6. Push Notification Payloads
7. The Service Extensions
8. The Content Extension
9. Rich Media in Notifications
10. Apple Watch Notifications
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.