Notification Actions and Categories
Add interactive actions to notifications.
Interactive Notifications
Notifications can do more than display text — they can offer buttons. A user can reply to a message, accept an invite, or snooze a reminder without opening the app. This is built from actions grouped into categories.
import UserNotifications
// Category = a set of actions
// Each delivered notification names its category
// so the system shows the right buttonsDefining an Action
A UNNotificationAction has an identifier (you match on it later), a localized title shown on the button, and options like .destructive or .foreground (which launches the app).
import UserNotifications
let accept = UNNotificationAction(
identifier: "ACCEPT",
title: String(localized: "Accept"),
options: [.foreground])
let decline = UNNotificationAction(
identifier: "DECLINE",
title: String(localized: "Decline"),
options: [.destructive])All lessons in this course
- Registering for Push Notifications
- Handling Notification Payloads
- Background Tasks and Refresh
- Notification Actions and Categories