🔔 [FCM] getInitialMessage() returns null on notification tap (data-only payload, app terminated) #17398
Unanswered
RahulSharma1224
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone 👋,
I'm implementing FCM with only data payload (no notification field) and handling custom local notifications using flutter_local_notifications.
✅ Works:
Notifications are received and displayed via flutter_local_notifications.
onSelectNotificationResponse works in foreground & background.
FirebaseMessaging.onMessage and onMessageOpenedApp work in active/paused states.
❌ Issue:
When the app is terminated, and a notification with only data is tapped:
getInitialMessage() returns null
onSelectNotificationResponse is not triggered
Action buttons (e.g., "Reply", "Cancel") do not respond
Custom sounds work only when app is in foreground/background, not terminated
❓ What I’ve tried:
Using flutter_local_notifications with payload
Handling notification tap via onSelectNotificationResponse
Using getInitialMessage() in main.dart
Setting click_action: FLUTTER_NOTIFICATION_CLICK
Setting high priority in FCM
🔍 Goal:
Handle action button callbacks
Open specific screens on notification tap
Play custom sounds
All while app is terminated (cold start)
📱 Target:
Android & iOS (latest OS versions)
Beta Was this translation helpful? Give feedback.
All reactions