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.

JSON payloads

JSON payloads

From the course: iOS and watchOS App Development: Notifications

Start my 1-month free trial

JSON payloads

- [Instructor] In the last chapter, I used a text payload for the push notification. That would be the simplest content, but has little flexibility. For more flexibility and power, it's a lot better to use a JSON payload. JSON is a way of organizing data in text. JSON files are text-based dictionaries encapsulated by curly braces. The simplest JSON dictionary would be this. This is a string-based key with one value. You can have more than one key prepared by separating them with commas. For values, you can have strings, numbers, arrays, Boolean values of true or false, or nul. You can also nest another dictionary as a value. Add curly braces for a value, and then add more keys inside the curly braces, like I did for key6 and 7 here, and making this dictionary key5. Without spaces, this tends to be harder for humans to read. You can use indents and new lines to make the code a little easier to read. Each curly brace is another level of dictionary with keys and values inside of it…

Contents