Sub topic 16
Why Notifications Sometimes Do Not Arrive
Start with the delivery path
Assume that you already have a Flutter app configured with firebase_core and firebase_messaging, and that you understand Dart async code and streams. Before changing code, identify which part of the delivery path failed.
A message travels through several systems:
A successful server request proves only that FCM accepted the message. It does not prove that the device received it, displayed it, or opened the expected screen.
Check the common causes
| Symptom | Likely cause | What to check |
|---|---|---|
| FCM rejects the request | Invalid token or credentials | Token value, Firebase project, service-account permissions |
| No message reaches the app | Expired or deleted token | Refresh and upload the current token |
| Message arrives but no banner appears | Permission, channel, or app-state behavior | Notification permission and Android channel settings |
| Tap opens the app but not the target screen | Payload or navigation handling | The `data` route and tap listeners |
| Android works but iOS does not | APNs setup problem | Push capability, APNs key, and physical-device testing |
Token and project problems
Registration tokens can change after reinstalling the app, clearing app data, restoring a backup, or rotating platform credentials. Store the latest token on your server whenever onTokenRefresh emits a value. Remove tokens after FCM reports them as invalid.
Also confirm that the sending credentials and the application belong to the same Firebase project. A token from one project cannot normally receive messages sent through another project.
Permission and platform restrictions
On Android 13 and later, the app must declare and request the POST_NOTIFICATIONS permission. The user can deny it or later disable notifications in system settings. Android notification channels also have user-controlled importance. If a channel was created with low importance, changing the code later might not change that existing channel. Delete the channel during testing or use a new channel ID.
On iOS, notifications require permission, an enabled Push Notifications capability, and valid APNs configuration in Firebase. Test iOS push delivery on a physical device. Simulator support does not represent normal APNs delivery.
App state and payload behavior
Foreground messages are delivered to FirebaseMessaging.onMessage, but Firebase Messaging does not automatically show a system notification while the app is visible. Use a local notifications plugin if the user needs a foreground banner.
Background notification messages are usually displayed by the operating system. Data-only messages are less reliable for background work because Android and iOS can delay, restrict, or omit background execution. A force-quit app may not receive background messages until the user opens it again.
Check message expiration, too. A short time-to-live can cause FCM to discard a message while the device is offline. Topics, battery-saving modes, network loss, and iOS Focus settings can also delay delivery.
A practical debugging order
- Log the token from the installed build and compare it with the server database.
- Send a simple notification from the Firebase console.
- Verify permission and operating-system settings.
- Check FCM response errors and server logs.
- Test foreground, background, and terminated states separately.
- Inspect the payload, especially the token, topic, route, and string-valued data fields.
Exercise
The server reports success, but no banner appears while the Flutter app is open. What should you check first?
Show answer
Check whether the app received the message through FirebaseMessaging.onMessage. Foreground messages do not automatically create a system banner, so verify notification permission and display a local notification if needed.