0Pricing
Swift Academy · Lesson

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 buttons

Defining 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

  1. Registering for Push Notifications
  2. Handling Notification Payloads
  3. Background Tasks and Refresh
  4. Notification Actions and Categories
← Back to Swift Academy