Back to results for “Deep Linking in Flutter”
Flutter › Deep Linking in Flutter

How can deep linking be combined with push notifications to let tapping a notification navigate a user directly to the specific relevant screen related to that particular notification's content?

Advanced

Answer

Combining deep linking with push notifications means each notification payload includes a specific deep link URL or a set of relevant identifying data, such as a specific order identifier, and when a user actually taps that notification, the app's notification handling logic extracts that specific data from the payload and then uses the exact same underlying deep link navigation logic already used for regular external deep links to navigate the user directly to the exact relevant screen, such as a specific order tracking page, providing a consistent, unified navigation experience whether a screen is reached through an external shared link or through tapping directly on a push notification.
FirebaseMessaging.onMessageOpenedApp.listen((message) {
  final orderId = message.data['orderId'];
  router.go('/orders/$orderId');
});
Real-world example A delivery tracking app includes the specific order identifier within every shipping update push notification's payload, and tapping that notification navigates the user directly to that exact order's live tracking screen using the exact same routing logic already used for regular shared deep links.

Common follow-ups: What is the difference in payload structure between a notification opened from a background state versus a completely terminated app state?;How do you test the specific combination of push notifications together with deep linking?