DevPrep

All topics › IDEs & SDK

Silent push and the Notification Service Extension: how to modify a notification before it is shown?

Senior PRO

The gist

There are two ways to run code on a push. A background (silent) push — "content-available": 1 without an alert: it shows nothing and wakes the app briefly to fetch data. A Notification Service Extension (NSE) — with "mutable-content": 1 the system launches your extension before showing the banner, and it modifies the content: decrypts text, downloads an image, replaces the title. The first is a "there is new data" hint with no guarantees, the second processes every visible notification.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store