Notifications give people information and functionality that’s important right now. People can get notifications in various contexts, such as on the lock screen, while they’re using apps, and when they visit Notification Center.
Notification Center has two views: Notifications and Today.
The Today view displays an editable list of widgets. A Today widget is an app extension that displays a small amount of timely, high-value information or functionality that’s provided by an app the user cares about. For example, the Calendar widget displays only today’s events. Tapping an event in the Calendar widget opens that event in the Calendar app, where users can edit the event and manage other events. To learn more about designing a Today widget, see Today Widgets.
The Notifications view displays recent notification items from apps that users are interested in. Users can visit an app’s area in Settings to specify whether they want notifications from the app to appear in Notification Center.
iOS apps can use notifications to let people know when interesting things happen, such as:
A message has arrived
An event is about to occur
New data is available for download
The status of something has changed
In iOS 8 and later, apps can define actions that users can take within a notification. For example, a notification from a to-do app might let users mark an item as done without having to open the app.
iOS defines two types of notifications.
A local notification is scheduled by an app and delivered by iOS on the same device, regardless of whether the app is currently running in the foreground. For example, a calendar or to-do app can schedule a local notification to alert people of an upcoming meeting or due date.
A remote notification (also called a push notification) is sent by an app’s remote server to the Apple Push Notification service, which pushes the notification to all devices that have the app installed. For example, a game that users can play against remote opponents can update all players with the latest move.
If you receive local or remote notifications while your app is running in the foreground, you’re responsible for passing the information to your users in an app-specific way.
To ensure that users can customize their notification experience, you should support as many as possible of the following notification types:
A banner is a small translucent view that appears onscreen and then disappears after a few seconds. Users can also see a version of the banner on the lock screen and in the Notifications view of Notification Center. In the banner, iOS displays your notification message and the small version of your app icon (to learn more about the small app icon, see App Icon). Users tap the banner to dismiss it and switch to the app that sent the notification.
In addition to a default action that users can take by tapping a banner, you can also define two actions that are revealed when users swipe the banner. Tapping a notification action button dismisses the banner and launches your app (possibly in the background) to handle the action.
A notification alert is a standard alert view that appears onscreen and requires user interaction to dismiss. You supply the notification message and either a default action or up to four specific actions that are revealed when users tap the Options button. You have no control over the background appearance of the alert.
When users tap a default or custom action button in an alert, iOS simultaneously dismisses the alert and launches your app (possibly in the background). Tapping the Close or OK button dismisses the alert without opening your app.
A badge is a small red oval that displays the number of pending notification items (a badge appears over the upper-right corner of an app’s icon). You have no control over the size or color of the badge.
A custom or system-provided sound can accompany any of the other three notification types.
Think carefully before enabling a destructive action in a notification. You want to be sure that users have enough context to avoid unintended consequences. To help users distinguish an action that you specify as destructive, iOS displays it in red. In some cases, it’s a good idea to require users to authenticate before your app performs a destructive action. For example, if you provide a destructive action in a banner that appears on the lock screen, you want to make sure that only the device’s owner can take that action (you’re responsible for implementing this requirement in code).
Provide a custom title for each action button. Create a very short title that clearly describes the action that occurs. For example, a game might use the title Play to indicate that tapping the button opens the app to a place where the user can take their turn. Make sure the title:
Uses title-style capitalization
Is short enough to fit in the button without truncation (be sure to test the length of localized titles, too)
Don’t send multiple notifications for the same event. Users can attend to notification items when they choose; the items don’t disappear until users handle them in some way. If you send multiple notifications for the same event, you fill up the Notification Center list and users are likely to turn off notifications from your app.
Don’t include your app name in the notification message. Your custom message is displayed in alerts and banners, and in the Notifications view of Notification Center. You don’t want to include your app’s name in your custom message because iOS automatically displays the name with your message.
To be useful, a local or remote notification message should:
Focus on the information, not user actions. Avoid telling people which alert button to tap or how to open your app.
Be short enough to display on one or two lines. Long messages are difficult for users to read quickly, and they can force alerts to scroll.
Use sentence-style capitalization and appropriate ending punctuation. When possible, use a complete sentence.
Keep badge contents up to date. It’s especially important to update the badge as soon as users have attended to the new information, so that they don’t think additional notifications have arrived. Note that setting the badge contents to zero also removes the related notification items from Notification Center.
Provide a sound that users can choose to hear when a notification arrives. A sound can get people’s attention when they’re not looking at the device screen. For example, a calendar app might play a sound with an alert that reminds people about an imminent event. Or, a collaborative task management app might play a sound with a badge update to signal that a remote colleague has completed an assignment.
You can supply a custom sound, or you can use a built-in alert sound. If you create a custom sound, be sure it’s short, distinctive, and professionally produced. (To learn about the technical requirements for this sound, see Preparing Custom Alert Sounds.) Note that you can’t programmatically cause the device to vibrate when a notification is delivered, because the user has control over whether alerts are accompanied by vibration.