Firebase Messaging Not Working in Flutter
·4 min read·Intermediate
Push notifications sent via Firebase Cloud Messaging (FCM) aren't being received on an Android or iOS device running a Flutter app, even though the send appears to succeed from the Firebase Console or backend.
androidiosflutterfirebasefcmpush-notifications
Advertisement
The Problem
Push notifications sent via Firebase Cloud Messaging (FCM) aren't being received on an Android or iOS device running a Flutter app, even though the send appears to succeed from the Firebase Console or backend.
Symptoms
- •Notification sent successfully from Firebase Console/Admin SDK, but never appears on the device
- •App receives notifications in the foreground but not when backgrounded or terminated (or vice versa)
- •Works on Android but not iOS, or vice versa
Why This Happens
- •google-services.json (Android) or GoogleService-Info.plist (iOS) is missing, outdated, or linked to the wrong Firebase project
- •On iOS, no valid APNs authentication key/certificate is configured in the Firebase Console — FCM relies on Apple's push service for delivery
- •Notification permission was never requested/granted on iOS (or Android 13+, which also requires runtime permission)
- •The FCM device token wasn't retrieved or wasn't sent to the backend triggering the notification
- •No foreground message handler registered — FCM does not automatically display a system notification while the app is in the foreground
- •Missing or incorrectly registered background message handler (must be a top-level or static function)
Quick Fix
Confirm the device actually has a valid FCM token and that notification permission was granted — these are the two most common root causes.
How to Fix It
1. Verify configuration and permissions (Android)
Confirm google-services.json in android/app matches the Firebase project you're sending from, and request notification permission at runtime on Android 13+:
final status = await FirebaseMessaging.instance.requestPermission();
print(status.authorizationStatus);
2. Verify APNs setup (iOS)
In the Firebase Console under Project Settings > Cloud Messaging, confirm an APNs Authentication Key (or certificate) is uploaded — without it, FCM cannot deliver to iOS devices at all. Also confirm Push Notifications capability is enabled in Xcode's Signing & Capabilities.
3. Request permission and check the token
final settings = await FirebaseMessaging.instance.requestPermission(
alert: true, badge: true, sound: true,
);
final token = await FirebaseMessaging.instance.getToken();
print('FCM token: \$token');
If getToken() returns null or throws, the app isn't registered with FCM/APNs correctly yet.
4. Handle foreground messages explicitly
FCM does not show a system notification while your app is in the foreground:
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
// show your own in-app notification/snackbar here
});
5. Register a top-level background handler
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
}
void main() {
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
runApp(MyApp());
}
Advertisement
Common Mistakes
- ×Testing push notifications on the iOS Simulator, which cannot receive real remote push
- ×Assuming a successful 'send' in the Firebase Console means delivery succeeded
- ×Forgetting foreground messages need a manually-built UI, unlike background/terminated notifications
How to Verify the Fix
- 1.Print and confirm a non-null FCM token on the target device
- 2.Send a test message directly to that token from the Firebase Console
- 3.Test all three app states separately: foreground, backgrounded, and terminated
- 4.On iOS, test on a physical device — APNs does not deliver remote push to the Simulator
Related Flutter Guides
Did this article save you time?
I write these for free. If it helped, a coffee keeps me going — and more articles coming.