Deliver silent notifications and wake up your app in the background on the user's device.
If your app’s server-based content changes infrequently, or at irregular intervals, you can use silent notifications to notify your app when new content is available. A silent notification is a remote notification that doesn't display an alert, play a sound, or badge your app’s icon. It wakes your app in the background and gives it time to initiate downloads from your server and update its content.
Enable the Remote Notifications Capability
To receive silent notifications, your app must support the remote notifications background mode. You configure this mode in the Capabilities tab of your project, as shown in Figure 1.
Create a Silent Notification
To send a silent notification, create a remote notification whose
aps dictionary includes only the
content-available key, as shown in Listing 1. You may include custom keys in the payload, but the
aps dictionary must not contain any keys that would trigger user interactions.
When an iOS device receives a silent notification, the system wakes your app in the background and calls the
application(_: method of its app delegate. Your app has 30 seconds of wall-clock time to perform any tasks and call the provided completion handler. For more information, see Handling Notifications and Notification-Related Actions.