Handling Notification Payloads
Respond to foreground and background notifications.
The Payload Structure
A remote notification is a JSON dictionary your server sends to APNs. The reserved aps key holds the user-visible content — alert, sound, badge — while any sibling keys carry your custom data, such as an item id to open.
// Example payload JSON:
// {
// "aps": { "alert": { "title": "Hi", "body": "..." },
// "sound": "default", "badge": 1 },
// "itemId": "42"
// }The aps Dictionary
Inside aps, alert can be a string or a title/body/subtitle object. sound, badge, and flags like content-available and mutable-content also live here. Everything outside aps is yours to define.
// aps keys:
// alert: { title, subtitle, body }
// sound: "default" or critical sound object
// badge: Int
// content-available: 1 (silent / background)
// mutable-content: 1 (allow modification)All lessons in this course
- Registering for Push Notifications
- Handling Notification Payloads
- Background Tasks and Refresh
- Notification Actions and Categories