User Notifications
Push user-facing notifications to the user’s device from a server, or generate them locally from your app.
Overview
User-facing notifications communicate important information to users of your app, regardless of whether your app is running on the user’s device. For example, a sports app can let the user know when their favorite team scores. Notifications can also tell your app to download information and update its interface. Notifications can display an alert, play a sound, or badge the app’s icon.
[Image]
You can generate notifications locally from your app or remotely from a server that you manage. For local notifications, the app creates the notification content and specifies a condition, like a time or location, that triggers the delivery of the notification. For remote notifications, your company’s server generates push notifications, and Apple Push Notification service (APNs) handles the delivery of those notifications to the user’s devices.
Use this framework to do the following:
Define the types of notifications that your app supports.
Define any custom actions associated with your notification types.
Schedule local notifications for delivery.
Process already delivered notifications.
Respond to user-selected actions.
The system makes every attempt to deliver local and remote notifications in a timely manner, but delivery isn’t guaranteed. The PushKit framework offers a more timely delivery mechanism for specific types of notifications, such as those VoIP and watchOS complications use. For more information, see PushKit.
For webpages in Safari version 16.0 and higher, generate remote notifications from a server that you manage using Push API code that works in Safari and other browsers.
For design guidance, see Human Interface Guidelines > Notifications.
Topics
Essentials
Notification management
Remote notifications
Setting up a remote notification serverSending push notifications using command-line toolsTesting notifications using the Push Notification Console
Notification requests
Web push notifications
Notification content
Implementing communication notificationsUNNotificationContentProvidingUNNotificationActionIconUNMutableNotificationContentUNNotificationContentUNNotificationAttachmentUNNotificationSoundUNNotificationSoundName
Triggers
UNCalendarNotificationTriggerUNTimeIntervalNotificationTriggerUNLocationNotificationTriggerUNPushNotificationTriggerUNNotificationTrigger
Notification categories and user actions
Declaring your actionable notification typesUNNotificationCategoryUNNotificationActionUNTextInputNotificationAction
Notification responses
Handling notifications and notification-related actionsUNNotificationResponseUNTextInputNotificationResponse
Notification service app extension
Entitlements
Sample code
Handling Communication Notifications and Focus Status UpdatesImplementing Alert Push NotificationsImplementing Background Push Notifications