Mobile Design Rounds
Case studyAndroidiOS15 min read

Design a push notification SDK (Android and iOS): tokens, payloads and delivery

Last reviewed . Drafted with AI assistance. Checked against official documentation where noted (how this is checked). Part of: The five-step method · Offline-first guide · Staff-level guide.

Build it. The database schema, API, code and platform limits for a push notification SDK are on a separate page: Build it: a push notification SDK on Android and iOS (20 min read).

How to read this. This page is a 45-minute round (the length I assume), in the order I would spend it. The API, server calls, Swift code and platform limits are in the build guide. The follow-up questions are my reconstruction of challenges that public prep material reports. They are not transcripts of real rounds.

TL;DR. My answer: the SDK (the push code library) keeps one correct record per device. A push is a hint, a signal that something changed. The host app (the app with the SDK) owns the permission prompt, the messaging service and the screens. The push address (the ID for the phone) can change. The SDK links it to a user, uploads it on change, and unlinks it at logout. On iOS the address is the APNs token, and a visible alert is shown by the system, so the server must stop sending to a logged-out device.

Patterns in this round.

More in design patterns in mobile rounds.

Free: one follow-up round a week. A short interview question with a weak and a strong answer, by email. You also get the cheat sheet.

1. Scope and constraints (minutes 0 to 4)

In short: Keep registration, logout and sync. Leave the sender backend, rich content and consent for later.

A prompt I would expect: "Design a push notification SDK for our mobile apps." I ask five questions, each with a default:

  • Who uses it? Five of our apps now, outside developers later.
  • Is the user logged in? Yes. A device is linked to a user until logout.
  • Do other SDKs use push? Yes.
  • Who shows the notification? The host app.
  • Who owns the backend? We do. I design the device registry, not the sender.
In scopeOut of scopeLater, if you ask
Register a device, link and unlink a userThe sender backendSending to millions
Permission state, receive, ignore repeatsCampaign toolsImages, reply buttons
Route taps, opt-outs, events, inbox syncThe inbox screenA second device, consent, a new address type

The phone adds four risks.

What the phone doesRequirement at riskDeep dive
The app is killed or force-stoppedA push may never arrivePush is a hint (4.2)
The push address changesThe server sends to a dead addressData and contracts (2)
The user turns notifications offWasted sendsPush is a hint (4.2)
Two people share a phone, or logout is offlineA message reaches the wrong personLogout (4.1)

Your decision. The scope grows to iOS and an inbox list. Do you build one design with two thin platform layers, or two separate SDKs?

First idea, and why it fails. Two SDKs, because the platforms look different. After a month, they handle logout in different ways. The server then supports two contracts, and each bug is fixed twice.

What I would say. I reject two SDKs. I use one record and one server contract. Each platform layer only reads the push address and asks permission.

Say this. "One design, two thin layers. The device record and the server calls are the same on both platforms. I skip the sender and the inbox screen. Tell me if you want them earlier."

The follow-up question I expect:

"A campaign hits two million devices in one minute."

That is follow-up 1. The other later items return as follow-ups 2, 3, 4 and 6.

45-minute plan

MinutesStepWritten down by the endCut if behind
0 to 4Scope and constraintsScope table, phone tableFewer questions
4 to 14Data and contractsinstallId, version counters, four callsThe numbers
14 to 22Client structureHost service, layers, who owns whatOne line per layer
22 to 40Make the hard part workLogout rules, push as a hintThe iOS bullets
40 to 45Break it, ship it, roll it backTop failures, kill switch (a remote flag that turns the SDK off), what I watchTwo failures and the switch

2. Data and contracts (minutes 4 to 14)

In short: The SDK makes its own device ID. The push address is only a value on that record.

Your decision. What identifies one device on the server? The push address, the user ID, or an ID that the SDK makes?

First idea, and why it fails. Use the push address as the key, and register it once. But the address changes after a restore, a reinstall or a new phone. The server then holds two rows and the user gets two pushes. Also, when user A logs out and user B logs in, the row is still linked to A.

What I would say. The SDK makes installId, a random UUID (a unique ID) saved on the device. The server uses it as the key. The push address is only a value on that row. Each upload is an upsert: insert the row, or update it if it exists. I reject the push address as the key. It looks simple, but it has no answer for logout.

The follow-up question I expect:

"The same phone sends two uploads at the same time."

Two uploads can overlap. The upload job records the version it sent, not the latest version.

  • Every local change adds one to localVersion.
  • If a change happens during the call, the versions differ, so the job uploads again.
  • The server keeps the higher version.

Where the installId lives matters:

  • Android Auto Backup and an iOS device or iCloud restore can copy files to a new phone. The new phone then has the same installId as the old one, and the two phones overwrite one row.
  • So keep the installId out of backups (on Android, noBackupFilesDir or a backup rule; on iOS, mark the file as excluded from backup). A restored app makes a new one.

The contract has four calls (details in the build guide):

  • Put a device: installId, push address and kind, user, topics.
  • Delete a device.
  • Post events: delivered and opened, each with a messageId.
  • Get the inbox after a cursor (a saved position that the server returns).

These numbers are assumptions, not measurements:

AssumptionArithmeticWhat it decides
10 million installs, 2 launches a day eachUpload on every launch: 20 million calls a day, about 230 a second. Upload every 7 days: 10 million / 7 is about 1.4 million a day, about 17 a secondUpload only on change, or when the last upload is old
Host app: 2 million installs, 5 percent on versions older than the kill switch2,000,000 x 0.05 is 100,000 installsThe server stays compatible first. The switch comes second

For FCM registration tokens (the older Android address), Firebase advises a refresh about once a month, with no gain above once a week. Its sample cleanup removes rows after 30 days. A 7-day refresh gives a row about 4 chances (30 / 7) before cleanup.

3. Client structure (minutes 14 to 22)

In short: The host app owns the one messaging service. The SDK owns a durable job and a local record.

Your decision. Who owns the messaging service and the long-lived work? The SDK, the host app, or an object that belongs to a screen?

First idea, and why it fails. The SDK declares its own messaging service (the Android part that receives pushes). Or the ViewModel of a screen (the object that holds screen state) starts the upload. The first fails when the host app or another SDK also declares a service. Which one Android calls is not something I would depend on, so the SDK may never run.

The second fails when the screen closes for good. Android then clears the ViewModel (ViewModel), and any coroutine started in its scope is cancelled (coroutines with lifecycle-aware components).

What I would say. The host app declares the one service. It forwards two calls to the SDK: a new push address, and a new message. The SDK answers "handled" or "not handled", so the host can pass the message on.

The work is a unique WorkManager job (the Android tool for work that must run reliably). Android documents it for work that must run even if the app exits or the device restarts (task scheduling). I reject a service declared by the SDK. Some vendors choose it because it needs no setup, but two services can conflict.

The follow-up question I expect:

"Host teams do not want to write the forwarding code."

I offer an optional base class to extend. The default stays explicit.

callsrecordaskmessageseventsreconcileuploadHost applogin, logout, permissionPublic APIconfigure, listenerToken registryrepository + state machineDevice recordtoken, user, opt-inPermission + channelshost decides timingDispatcherroute, dedupeSync workerWorkManagerFCM / APNsbest effort hintsBackenddevice registryHost applogin, logout, permissioncallsPublic APIconfigure, listenerToken registryrepository + state machinerecordDevice recordtoken, user, opt-inPermission + channelshost decides timingDispatcherroute, dedupeSync workerWorkManagerFCM / APNsbest effort hintsBackenddevice registry

More links

  • Public API to Permission + channels: ask
  • FCM / APNs to Dispatcher: messages
  • Dispatcher to Token registry: events
  • Token registry to Sync worker: reconcile
  • Sync worker to Backend: upload
Push SDK architecture: the SDK is a state machine around one device record; provider messages and host calls update it, and one worker reconciles it with the backend.

On iOS, the app has one notification delegate (an object that receives notification events). So the SDK installs a proxy that forwards to the host's delegate. Three rules:

  • Everything is internal until a user needs it.
  • No screen toolkit types in the public API.
  • The SDK never opens a screen. It gives the host a link.

4. Make the hard part work (minutes 22 to 40)

In short: Logout must be safe offline. A push says only "something changed", and a sync fetches the content.

4.1 Logout and the shared phone (minutes 22 to 31)

Your decision. The user logs out, and the phone has no network. What does the SDK do with the device record?

First idea, and why it fails. Delete the push address, call the server, and wait. Offline, the call fails, so the old user stays linked to the phone and the next user gets the old pushes.

What I would say.

Say this. "On logout I clear the user on the device first and add one to the version. Then I queue the unlink call, and I clear the local inbox. Offline logout cannot leak, because the server also unlinks when a new user claims the same installId. On Android the client ignores any push whose user does not match. On iOS the system shows an alert without running my code, so the server stops sending to an unlinked install, and the alert text is generic until the app can check the user."

I reject waiting for the server before I clear local state. It can expose the next user until the phone is online again.

The follow-up question I expect:

"Two people share one phone."

This is logout again, with two real people. The same three guards apply.

  • Clear local state first, then queue the unlink.
  • The server relinks when a new user claims the same installId.
  • On Android, the client shows nothing for a push that belongs to another user.

On iOS the third guard works differently:

  • The system shows a visible alert before any app code runs. A Notification Service Extension can rewrite the text, but I cannot rely on it to drop the alert.
  • So the server is the main guard. It stops sending to an installId that has no user, and it relinks on the next claim.
  • The alert text is generic, for example "You have a new message". The extension or the app fills in details only after it checks that the user matches.
  • The hint names the user it is for (a user ID), so the client can make that check.

The follow-up after that: "The app is killed right after logout, before the unlink call went out."

  • The queued unlink is a row on disk. It is written in the same transaction that clears the user and adds one to localVersion.
  • At the next launch, the SDK sends that row first. The call carries the same installId and version, so sending it twice changes nothing.
  • An unlink kept only in memory is lost with the process. Then the old user stays linked until a new user claims the install.
  • After logout, the queued unlink cannot use the old user's login. In my design it goes out with a device credential tied to installId, or the SDK keeps the old token for that one call. If the server answers 401, I drop the row. The server relinks on the next claim.

4.2 Push is a hint (minutes 31 to 40)

Your decision. The app is closed. How does the message reach the user, and what does the push carry?

First idea, and why it fails. Put the whole message in the push and show it. But a push can be lost. One cause is a force-stop at delivery time (delivery post). Others are more than 100 waiting pushes, or a month offline (receive messages). Doze (the deep-sleep mode of an idle phone) can delay pushes of normal priority (priority).

What I would say.

Say this. "A push carries only a hint: a message ID, a type and an entity ID. The client then asks the inbox for everything after its last cursor. That sync repairs any gap, so a dropped push costs a delay, not a message. I ignore repeats by message ID."

I reject silent push (a push with no visible alert) as the way to get correctness. The host shows the permission prompt. The SDK only reads the permission state at each foreground.

If I am interrupted, I answer first, then return:

Say this. "Yes, the same message twice is normal here. The message ID makes the second copy change nothing, so the user sees one entry. Now back to the push path, where I was."

The follow-up question I expect:

"A user says the push never arrived."

The SDK sees only part of the path. I go through a list, and I say which checks the SDK can make.

  • It can see: permission state, the channel setting, and the time of the last sync.
  • It cannot see: losses inside the push service, force-stop, and phone-maker battery limits.
  • The sender side adds priority, collapse key (which replaces an older waiting message) and time to live. Firebase also warns that "delivered" does not mean "shown".

The follow-up after that: "The app is killed in the middle of an inbox sync."

  • I move the cursor only after the items of that page are saved. Both writes go in one transaction.
  • If the cursor moved first, the items of that page would never be fetched again. The user would miss messages with no error.
  • After a restart, the sync asks again from the old cursor. Items that were saved are ignored by message ID.
  • The delivered and opened events wait in the same kind of outbox. They are resent with the same messageId.
Serversends the push, keeps the inboxPush: a hintmessage ID, type,entity IDInbox syncask for all aftermy last cursorThe SDK on the phonea repeat of a message ID changes nothingKill switch: a remote flagturns the SDK off, only in versionsthat already have it; not for startup crashes
A push carries only a hint and can be lost. A sync that asks the inbox after the last cursor repairs any gap. A remote kill switch can turn the SDK off.

4.3 Where iOS changes the design

The design is the same: one record, one server contract, push as a hint. The Swift code is in the build guide.

Registration and the address.

  • The host calls registerForRemoteNotifications() at every launch. The token arrives in didRegisterForRemoteNotificationsWithDeviceToken, and the SDK uploads it only when it changed.
  • A token belongs to one environment, sandbox or production. The record stores the environment, because a sandbox token sent to production fails with BadDeviceToken.
  • If the host uses Firebase on iOS, the FCM token is a different value from the APNs token. Firebase can also take over the notification delegate (method swizzling), so the SDK must not assume it owns the app delegate.

Durable work.

  • iOS has no WorkManager. The SDK keeps its own outbox (a saved list of work the server has not confirmed) and sends it at launch, at foreground and on a push.
  • For work after the app is suspended, a background URLSession upload or a BGProcessingTask can help. Neither promises a time, so the outbox stays the base.

What the push looks like.

  • A silent push is low priority and not guaranteed. A waiting one is discarded after a force-quit (Apple). So I send a visible alert with mutable-content: 1 and generic text. The hint (message ID, type, entity ID, user ID) rides in the same payload.
  • A Notification Service Extension (a small separate process) can then fetch details within about 30 seconds and replace the text.
  • Set the notification delegate before launch ends, or the app can miss incoming notifications. The SDK installs a proxy that forwards to the host's delegate.

5. Break it, ship it, roll it back (minutes 40 to 45)

In short: Each failure ends in a late push or a clear state, never in a message for the wrong person.

FailureUser seesData holdsRecovery
Background kill or throttleA late or missing pushLast cursorCursor sync at next launch
Account switch with pending workNothing from the old userUser cleared, version raisedServer relink, client ignores the push
App killed during logout or syncNothing from the old user, no gap in the inboxQueued unlink, cursor saved with its itemsSend the unlink first at next launch, sync from the saved cursor
Unlink runs after the login is goneNothing from the old userQueued unlink rowUse the device credential or the one-call token. On a 401 drop the row; the server relinks on the next claim
Duplicate deliveryOne entryTable of seen message IDsRepeats ignored
Long offline gapThe latest itemsLast cursorFull sync after onDeletedMessages
Permanent rejectionNothing, the server stops sendingRow removedRegister again at next launch
Old app version meets new server contractNothing, if the server keeps bothOld SDK rowsServer accepts every version

Rows not linked to a source are my design choices. Sources are in Further reading.

At release:

  • A store can pause a rollout but not recall it. Play says users who have the update keep it (Play help). Apple allows a pause of up to 30 days (Apple) and says nothing about reverting.
  • Old SDK versions can stay in host apps for a long time, because users update slowly. The server accepts every version. I add fields but never reuse them.
  • The host app's kill switch for the SDK is a remote flag. It works only in versions that already contain it, and it cannot fix a crash at startup.
  • A change to the public API or the local schema cannot be flagged. It waits for a major version.

Say this. "I cannot recall a bad SDK build, so the rollback is the host's kill switch plus a fixed build. I would watch registration success and uploads by SDK version. I left out the sender, rich content and consent."

6. Follow-ups that change a constraint

In short: Each follow-up changes one constraint. A strong answer says what breaks.

Practice prompts, not a claim about what any interviewer asks.

  1. A campaign hits two million devices in one minute. Strong: many devices ask the inbox at once, so I add a random delay to the sync and collapse state-only pushes. Weak: "The server will scale."
  2. Add images and reply buttons. Strong: on iOS, an extension (a separate process) fetches the image within its time limit. A reply must reach the backend with the app closed. Weak: "Put the image in the push."
  3. The user reads a message on the phone, and the tablet still shows it. Strong: read state lives in the inbox. Each device has its own installId, and the tablet learns by a hint and a sync. Weak: "Ignore it."
  4. A user withdraws consent, or asks for erasure. Strong: events stop at once, and the delete call removes the device row. Payloads are never logged. Weak: "Delete the push address."
  5. After an SDK release, registration success drops. Strong: I compare success by SDK version. The kill switch cannot fix a startup crash, so I pause the rollout and ship a fixed build. Weak: "Roll back the release."
  6. The platform moves from tokens to installation IDs while three SDK versions are in use. Strong: the record has an address kind, the server routes by kind, and the SDK accepts both. Weak: "Force everyone to update."

7. What changes by level

In short: The levels differ in who raises the problem.

These levels are my own reading of the bar, drawn from vendor and prep material (courses and books), not any company's rubric. The wording is mine.

  • Mid-level: get the address, upload it on change, ask permission in context, open the right screen on tap. I want to hear: "A push is a hint, so I sync after it."
  • Senior: the upsert by installId, safe offline logout, push as a hint with an inbox, a host-owned service. I want to hear: "Logout clears the inbox and unlinks first, because the unlink call can fail offline."
  • Staff: API stability over years, delivery measurement and its blind spots, a tested kill switch. I want to hear: "I revisit this when too many installs run versions older than the kill switch."

As I read it, the interviewer raises the problem at mid level. The candidate raises it at senior level, and adds a rollout plan at staff level.

Common weak answers. Ten minutes on queues and sending, which is backend work. Only the normal case, with no lost pushes. Naming FCM (Firebase Cloud Messaging, the Google push service) without saying what breaks. The push address as the key. No rollout plan. These patterns repeat across prep material. They are not a dataset.

Staff answer: the decision and the rollout

  • Decision: one SDK with a server-controlled kill switch and a registration protocol that keeps working with old versions, not separate integrations in each app.
  • Alternative: each team builds its own FCM and APNs (the Apple push service) integration. Apps then handle addresses in different ways.
  • Revisit trigger: if most traffic comes from versions without the kill switch, I fix server compatibility first.
  • Rollout: sample app, then one host app, then the rest.
  • Guardrail: test the kill switch in a drill. A new version must not lower registration success.

What I read and what is my view: I read the FCM, Android, Apple and store-rollout facts in official pages. The design, the numbers, the drill and the level text are my opinion. The staff mobile loop guide covers the wider decision.

Test yourself

In short: Seven questions from this case. Answer each one out loud first, then open the answer.

1. What identifies a device on the server, and why not the push address?

An installId, a random UUID that the SDK makes and saves on the device. The push address changes after a restore, a reinstall or a new phone, which would leave two rows. It is only a value on the row. Each upload is an upsert.

2. Who declares the messaging service, and why not the SDK?

The host app declares the one service and forwards two calls to the SDK: a new push address and a new message. If the SDK declared its own, a second service from the host or another SDK could conflict, and the SDK might never run.

3. The user logs out with no network. What does the SDK do?

It clears the user on the device first, adds one to the version, clears the local inbox and queues the unlink call. Offline logout cannot leak, because the server also unlinks when a new user claims the same installId, and the client ignores a push for another user. On iOS the system shows alerts itself, so the server stops sending to an unlinked install and the alert text stays generic.

4. What does a push carry, and why?

Only a hint: a message ID, a type and an entity ID. A push can be lost, for example after a force-stop. The client then asks the inbox for everything after its last cursor, so a dropped push costs a delay, not a message.

5. The same message arrives twice. What does the user see?

One entry. The message ID makes the second copy change nothing.

6. Why not upload the device record on every launch?

With 10 million installs and 2 launches a day that is 20 million calls a day, about 230 a second. Upload only on change, or when the last upload is old, for example every 7 days.

7. Why does the device record store the push environment on iOS?

A token belongs to one environment, sandbox or production. A sandbox token sent to production fails with BadDeviceToken. So the record stores the environment next to the token.

Further reading (official docs)

Further reading (other, not official)

Prep material that shaped the questions I asked. These are references, not sources of wording. I read only the public parts of the commercial ones.

  • The push notification SDK lesson from the DesignGurus mobile course
  • The weeeBox mobile design repository
  • The mobile push and token management articles on techinterview.org
  • The Android push documentation of Customer.io, an example of the other pattern: the SDK declares the service
Words on this page (18)
APNs
Apple Push Notification service, the push service from Apple. Every push to an iPhone goes through it.
Coroutine
A light background task in Kotlin. It can pause and continue later without blocking a thread.
Cursor
A saved place in a list. The server gives it to the app, and the app sends it back to get the next part.
Doze
The deep-sleep mode of an idle Android phone. It pauses network access and delays background work.
FCM
Firebase Cloud Messaging, the push service from Google. On iOS it passes the push to APNs.
Host app
The app that contains an SDK. You write the SDK, and another team writes the host app.
Kill switch
A remote flag that turns a feature off at once. It is the one rollback that reaches apps that are already installed.
Outbox
A saved list of changes that the server has not confirmed yet. The app sends them later, even after it restarts.
Push address
The ID that a push service gives to one app on one phone. The server needs it to send a push, and it can change.
Remote flag
A setting that the server can change. It can turn a feature on or off without a new release.
Repository
The class that reads and writes data for the rest of the app. It hides whether the data comes from the network or the database.
Rollback
Going back to the old behavior after a problem. A build on a user's phone cannot be taken back, so teams use a kill switch.
SDK
Software development kit. Code that other developers add to their own apps.
Silent push
A push with no visible alert. The system can delay it or drop it, so treat it only as a hint.
Upsert
A database step that inserts a row, or updates it if it already exists.
UUID
A random unique ID. Two devices almost never make the same one.
ViewModel
A class that holds the state of one screen. It survives a screen rotation.
WorkManager
Android's tool for background work that must run later. The work survives when the app closes or the phone restarts.

Read the whole glossary

Verification notes (last reviewed 14 Oct 2026)

What I checked on official pages (14 Oct 2026).

  • Firebase: tokens go stale after a month; Android registrations expire after 270 days; refresh about monthly, with no gain above weekly; the sample cleanup uses 30 days.
  • Firebase: more than 100 pending messages, or more than a month offline, can drop messages and call onDeletedMessages. Normal priority can be delayed in Doze. A force-stopped app drops messages. "Delivered" does not mean "shown".
  • Android: a ViewModel is cleared when its screen goes away for good. WorkManager work persists across restarts. POST_NOTIFICATIONS needs API 33.
  • Apple: background pushes are low priority, not guaranteed and may be throttled. A held one is discarded after a force-quit. Set the notification delegate before launch ends.
  • Play: users who have an update keep it after a halt. App Store Connect: a phased release can be paused for up to 30 days, with no mention of reverting.

My own design, not documented rules.

  • The installId key, the version counters, the logout rules, the numbers, the failure rows, the scripts and the level text.
  • The follow-up questions are my reconstruction from public prep material, not transcripts of real rounds.

What I did not verify.

  • Which service Android calls when two share an intent filter. The design avoids it.
  • Details of FCM installation-ID mode (see the build guide).
  • No iOS engineer has reviewed the iOS parts.

Questions or corrections?

Add them to the discussion thread for this case on GitHub. To post, you need a free GitHub account. What you write there is public and follows GitHub's terms. Good answers are added to this page.

Keep reading

Get the free one-page cheat sheet

One page: the five steps, a 45-minute time plan and two checklists. Print it or keep it on your phone.

We email you the cheat sheet after you confirm your address. You can also open it now from the Start here page. You also get a short email each week with a follow-up round, and a note when a new case is published. Unsubscribe any time. Privacy.