Detect if the app was launched/opened from a push notification
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Detecting whether an app was opened from a push notification is mostly a question of app state. A cold start, a background resume, and an already running app all enter through different platform callbacks, so a reliable implementation needs to handle those entry points intentionally.
Think in Terms of Launch Paths
The phrase "opened from a push notification" can mean different things:
- the app was not running and launched because the user tapped a notification
- the app was in the background and resumed because of a notification tap
- the app was already running and the notification interaction still triggered navigation
If you only handle one of those paths, the feature works sometimes and fails in ways that are hard to reproduce.
Android: Put Context into the Launch Intent
On Android, the common pattern is to build the notification with a PendingIntent that starts an activity and includes extras marking the navigation as push-driven.
Then inspect that intent in both onCreate and onNewIntent, because the activity might be created fresh or reused.
That covers both cold start and reuse of an existing activity instance.
iOS: Use the Notification Response Callback
On iOS, a user tap on a notification is delivered through UNUserNotificationCenterDelegate. The response object contains the original payload.
For older app-delegate-style launches, similar payload information may also appear in launch options. The important design choice is the same: convert the raw notification payload into typed app navigation state as early as possible.
Separate Detection from Navigation
Do not scatter push-checking code across multiple screens. A cleaner flow is:
- detect the push entry point
- normalize the payload into a small internal model
- route the app through one navigation function
That keeps notification handling testable and avoids duplicate logic.
The same principle applies on iOS. Raw dictionaries are a transport format, not the ideal shape for application logic.
Do Not Confuse Delivery with Open
Receiving a push while the app is already in the foreground is not the same as the user opening the app from a notification. Those are separate events and should be tracked separately in analytics and behavior.
If you merge them, notification reports become misleading and UI routing logic becomes harder to reason about.
Common Pitfalls
- Handling only cold start and forgetting resumed or reused activity cases.
- Treating message receipt as proof that the user opened the app from the notification.
- Parsing raw payloads in many places instead of normalizing them once.
- Forgetting to replace stale intent data when Android reuses an activity instance.
- Mixing analytics tracking and navigation until both become fragile.
Summary
- Push-open detection depends on the app state and entry point.
- On Android, pass extras in the launch intent and handle both
onCreateandonNewIntent. - On iOS, handle notification taps through the notification response callback.
- Normalize payloads into app state before navigating.
- Keep notification delivery and notification open as separate concepts.

