Use `FirebaseMessaging.instance.getInitialMessage()` during app startup. That is the API that tells you whether the app was cold-started from a notification tap while terminated. Example: ```dart final navigatorKey = GlobalKey<NavigatorState>(); Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp(navigatorKey: navigatorKey)); final initialMessage = await FirebaseMessaging.instance.getInitialMessage(); if (initialMessage != null) ...
Scanned 9/5/2026
Install to Claude Code
npx -y skills add HoangNguyen0403/agent-skills-standard --skill flutter-notifications --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Flutter Notifications?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-notifications-2721e578)More formats (shields.io, HTML) on the badges page.
Use `FirebaseMessaging.instance.getInitialMessage()` during app startup. That is the API that tells you whether the app was cold-started from a notification tap while terminated.
Example:
```dart
final navigatorKey = GlobalKey<NavigatorState>();
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp(navigatorKey: navigatorKey));
final initialMessage = await FirebaseMessaging.instance.getInitialMessage();
if (initialMessage != null) {
_handleNotificationNavigation(initialMessage.data);
}
}
void _handleNotificationNavigation(Map<String, dynamic> data) {
final orderId = data['orderId'];
if (orderId is! String || orderId.isEmpty) return;
navigatorKey.currentState?.pushNamed(
'/order-details',
arguments: orderId,
);
}
```
You should also handle the other app states:
```dart
FirebaseMessaging.onMessageOpenedApp.listen((message) {
_handleNotificationNavigation(message.data);
});
```
Key points:
- Use `getInitialMessage()` for the terminated state.
- Validate the payload before navigating, for example make sure `orderId` exists and is valid.
- Register your route/navigation setup before trying to push.
- If you support foreground notifications too, use `flutter_local_notifications` for display, but terminated-launch navigation still comes from `getInitialMessage()`.
Is this your skill, or is something wrong with this listing? . Author removals are honored within 72 hours.
No comments yet. Be the first to comment!