Lorixen.
EN

Push notification taps that open the right screen

Short answer: When a customer taps "Your order has shipped" or "Your booking is tomorrow", the app should open that order or booking, not the home screen, and the Back button should lead somewhere sensible. To get there, include an identifier or a link path in the notification payload, handle the tap in the app's notification-response code on iOS and the notification's intent on Android, route to the screen once the app is ready and the user is signed in, and build a proper back stack. Test it with the app closed, in the background and already open.

Why it matters

A notification is an invitation to do something specific. If tapping it drops customers on a home screen, they have to hunt for the order or message, and many won't. It also feels broken, which makes people more likely to turn notifications off entirely.

Step 1: Put the destination in the payload

Each notification needs to say where it leads. Two common approaches:

  • An identifier and type, such as type: "order" and order_id: "84731", which the app maps to a screen.
  • A link path, such as /orders/84731, using the same routes your app already uses for deep links from emails or websites.

Using one routing system for notifications, emails and web links keeps things consistent: a notification is just another way to open a link.

Never include sensitive details in the payload; send an ID and let the app load the details securely after sign-in.

Step 2: Handle the tap on iOS

Apple's documentation for the notification center delegate's userNotificationCenter(_:didReceive:withCompletionHandler:) method describes it as asking the delegate to process the user's response to a delivered notification. The response can indicate a custom action, a dismissal, or that the user launched the app without choosing a custom action, and your implementation must call the completion handler when done.

In practice:

  1. Set the notification center delegate early, at app launch, so taps that start the app aren't missed.
  2. In the response method, read the payload, work out the destination and hand it to your app's router.
  3. Call the completion handler promptly.

Step 3: Handle the tap on Android

Android's guide to starting an activity from a notification distinguishes two cases:

  • Regular activity: a screen that's part of the app's normal flow. The guide says the new task must include a complete back stack so the user can tap Back to move up the app's hierarchy. It recommends building the notification's PendingIntent with TaskStackBuilder, after defining each activity's parent with android:parentActivityName.
  • Special activity: a screen only shown from a notification that extends the notification's content. It doesn't need a back stack and can use a simple PendingIntent.

For apps built with a navigation library or a single activity, the same idea applies: when opening the order screen from a notification, make sure Back leads to the orders list or home, not out of the app.

Step 4: Wait until the app is ready

Most broken notification taps happen because the app isn't ready to navigate yet:

  • Cold start: the app was closed. The tap arrives while it's still loading. Store the destination and navigate once the main screen is ready.
  • Signed out: the customer must log in first. Keep the destination, show login, then continue to the order.
  • Data not loaded: show the screen with a loading state rather than waiting on a blank screen.
  • Item gone: if the order was deleted or belongs to another account, show a friendly message and a way back.

Step 5: Cross-platform frameworks

React Native, Flutter and other frameworks have notification libraries that expose "notification opened" events, including one for the notification that launched the app. Check you handle both: the event while running, and the initial notification on cold start. Missing the second is the most common bug.

Step 6: Test every state

For each notification type, test on both platforms:

App state Expected
Closed Opens straight to the right screen after launch
In background Comes to front on the right screen
Open on another screen Navigates to the right screen
Signed out Login first, then the right screen
Item no longer exists Clear message, no crash

Then press Back from the destination and check where it goes.

Measure it

Track notification opens and whether the destination screen loaded. A gap between opens and successful destination views points to routing bugs.

Action buttons on notifications

Some notifications carry buttons, such as "Track parcel" or "Reschedule". Each button is a separate action and should lead to its own destination, or complete a small task without opening the app at all. Apple's documentation notes that the response tells you whether the user picked a custom action or simply opened the app, so check which one before routing. Keep the number of buttons small, label them with verbs, and test each one in every app state, as with the main tap.

An illustrative example

A hypothetical Christchurch car-servicing business had an app that sent "Your car is ready for collection" notifications, but tapping them always opened the home screen, and after a cold start customers sometimes saw a blank page. The developer added a booking ID to the payload, set the notification delegate at launch on iOS, stored the destination until sign-in completed, and used TaskStackBuilder on Android so Back led to the bookings list. Support messages asking "where's my booking?" dropped noticeably.

FAQ

Do I need separate code for each notification type?

Use one router that maps types or paths to screens, so new types are a small addition.

What if the user taps an old notification?

Handle it gracefully: load current data and show a message if the item has changed.

Should tapping open a web page instead?

Only if the content lives on the web. Keep customers in the app where possible.

Can a notification open a specific tab?

Yes, as long as your router can navigate to it.

If tapping your app's notifications opens the wrong place or nothing at all, tell us which notifications and platforms.

Sources

WhatsAppBook a call