MSD-101 · Deep dives: hard problems, solved
Push notifications that arrive
⏱ 11 min 🎮 Hands-on ☁ Azure ✓ Completed
⚡ The 30-second answer
Push notifications are best effort: they can be late, merged or dropped. Send them through Azure Notification Hubs (FCM v1 for Android, APNs for iOS) to a tag for the person, update the device installation on every app start, push only state changes with short text and no personal data, and let the app re-read the truth when it opens.
- One hub for Android and iOS
- Installations and tags
- Push only state changes
- Lock-screen privacy
Try it
Play with the design before you read about it. Everything runs on this page.
No Azure subscription needed. Read the requirement, see the architecture, build it in a mock portal, send a booking through it, then break it.
☁ Simulate on Azure: Push notifications that arrive
Priya's driver has arrived. Her phone is locked, in battery saver, and she reinstalled the app yesterday. She must still find out, and nobody looking at her lock screen should see private details.
It must
- Tell riders and drivers about state changes when the app is closed
- Reach Android (FCM) and iOS (APNs) from one place
- Target a person, not a device
- Show the true state when the app opens
With these numbers
- Delivery
- Best effort, seconds
- Devices
- 10M installs
- Pushes per trip
- ≤ 6
- Lock screen
- No personal data
Each box is one Azure service. Tap a box (or Tab to it) to see its job and why it is there.
Create each resource. The defaults are a good design; change a setting and read why it matters. Some choices decide what breaks later.
Home › Create a resource › Azure Notification Hubs
Create Notification Hub
ⓘ Free is for testing with few devices; production needs a paid tier.
ⓘ Google retired the legacy FCM API; use FCM v1.
Deployment in progress…
Microsoft.NotificationHubs · resource group rg-push
Home › Create a resource › iOS / Android
Remote config: rider app push
ⓘ Device tokens change after reinstalls and restores.
ⓘ Lock screens are public; the app shows details after unlock.
ⓘ Pushes can be late, merged or dropped.
Deployment in progress…
Microsoft.iOS/Android · resource group rg-push
Home › Create a resource › Azure Container Apps
Trip service: push rules
ⓘ Live location goes over the WebSocket, never as pushes.
Deployment in progress…
Microsoft.ContainerApps · resource group rg-push
Everything is deployed. Your architecture is lit up below. Go to Run to send a request through it.
Request: Driver arrived: tell Priya
⚠️ Notification Hubs Free is fine for a test. Use a test Firebase project and an Apple development certificate or key.
- Create a Notification Hub and add FCM v1 and APNs credentials.
- In the app, create or update an installation on every start, tagged with the user id.
- Send a test push to the tag from the portal's Test Send.
- Delete the resource group when done.
* Illustrative prices to compare designs, not a quote.
What breaks, and the fix
| Failure | User sees | Why | Fix |
|---|---|---|---|
| 🔄 Priya reinstalled the app yesterday | No notification at all | An old device token | Update the installation on every app start |
| 🔋 Battery saver delays the push | Wrong status from an old push | Push delivery is best effort | Re-read the trip when the app opens |
| 🌪️ Every location update sent as a push | Notifications turned off | Too many pushes | Push only state changes; location on the WebSocket |
| 👀 Phone on a café table, screen locked | Private data on the lock screen | Full details in the push | Short text; details after unlock |
| 🔒 Google switches off the legacy API | Android pushes stop | Retired legacy FCM API | FCM v1 credentials in Notification Hubs |
🎓 Education-only simulation. Nothing is created in Azure and no subscription is needed.
Stream vs command
Live data can lose a point. Commands must happen exactly once. Give them different roads.
GPS points ride the WebSocket every 4 s. One lost? The next one replaces it.
Idempotency key
Send the same ID on every retry. The server returns the first result instead of doing it again.
Book with key k7. The trip is saved… but the reply is lost in the lift.
Outbox + backoff
Save the command on the phone first, then send it. Wait longer after every failure.
The tap is saved to the local outbox. Even if the app dies now, it is not lost.
Geo index + expiry
Keep only the latest position per driver in memory, and let it expire after 30 s.
Every ping overwrites the driver’s last position and resets a 30 s timer.
Pub/sub fan-out
Publish one event to a group. Everyone in the group gets it, however many they are.
The trip service publishes once: “car moved”.
Push to wake, then re-sync
A push only says “something changed”. The app then asks the server for the truth.
The app is in the background, so its socket is closed. The server sends a push.
- The problemPriya reinstalled the app yesterday. Today her driver arrives and waits 5 minutes outside. She never got the push: it went to her old device token.
- The design ideaA push says “look”; the server says what happened.
- In real lifeApps that push too often see users turn notifications off within days, and both mobile platforms limit how often a background app can be woken.
Start with a question
Priya reinstalled the app yesterday. Today her driver arrives and waits 5 minutes outside. She never got the push: it went to her old device token.
Pushes travel through Google and Apple, not your servers. Design for the parts you do not control.
Explain it like I'm 10
A push is like a note under the door: it says “something changed, come and look”. You still open the door to see what really happened.
The technical explanation
One hub. The trip service sends once to Azure Notification Hubs with a tag like user:42. The hub delivers through FCM v1 (the legacy FCM API was retired in 2024) and APNs to all of that person’s devices.
Fresh registrations. On every app start, create or update the device installation with the current token and the user tag. Tokens change after reinstalls, restores and OS updates.
Few, safe pushes. Push only state changes (driver matched, arrived, trip ended, receipt): about five per trip. Live location stays on the WebSocket. Lock screens are public, so use short text without names, plates or addresses.
Trust the server, not the push. When the app opens, it calls GET /trips/{id} and shows that. A late push then does no harm.
| Rule | Why |
|---|---|
| Tag by user, not device | Reaches every phone the person uses |
| Update installation on start | Tokens change after reinstalls |
| FCM v1 credentials | Legacy FCM API is retired |
| Only state changes | No throttling, no muted apps |
| Short text, re-sync on open | Privacy and correctness |
Real-world scenario
Apps that push too often see users turn notifications off within days, and both mobile platforms limit how often a background app can be woken.
Test yourself
5 questions. Get 4 right and this lesson is marked complete.
Pass the quiz to complete this lesson.
Next: Mock interview: design the taxi app in 45 minutes →Questions people ask
Are push notifications guaranteed to arrive?
No. Delivery through FCM and APNs is best effort and can be delayed by battery saving or dropped. Design the app to re-read the state when it opens.
What is the difference between a WebSocket message and a push notification?
A WebSocket message reaches an app that is open and connected, in under a second. A push reaches a closed or backgrounded app through Google or Apple, with no timing guarantee.
Can I skip push and just use the WebSocket?
No. Mobile platforms close sockets soon after an app goes to the background. Push is the only way to reach a closed app, so you need both: the socket for live data, push for “come back and look”.
Interview questions
How this topic comes up in system design interviews. Answer out loud first, then open the model answer.
beginner Why use Azure Notification Hubs instead of calling FCM and APNs yourself?
One API and tag system for both platforms, it manages device installations and scales to millions of devices.
intermediate Design notifications for a ride app.
Trip service emits state changes (from the change feed) → Notification Hubs to tag user:{id} → FCM v1 / APNs; installations updated on every app start; short text; app re-syncs on open; live data on WebSocket only.
Quick revision
Remember
- One hub for Android and iOS
- Installations and tags
- Push only state changes
- Lock-screen privacy
- Add an in-app status as well as the push. If the push is late, the app still shows the right state the moment it is opened.
One line to remember
“A push says “look”; the server says what happened.”
Official documentation
- Notification Hubs overview (Microsoft Learn)
- Migrate to FCM v1 (Microsoft Learn)