Flutter Integration

Flutter Push Notifications Setup: Firebase Cloud Messaging (2026)

Push notifications require Firebase Cloud Messaging (FCM) for cross-platform delivery. On iOS, you also need an APNs key from the Apple Developer Portal. This guide walks through the complete setup for both platforms.

Prerequisites

  • A Firebase project
  • Flutter SDK installed
  • For iOS: Apple Developer Program membership ($99/year)
  • For Android: Google Play Console or just a physical device

Step 1: Set up Firebase project

Go to console.firebase.google.com and create a project. Add an iOS app and Android app to the project. Download the config files:

  • iOS: GoogleService-Info.plist — place in ios/Runner/
  • Android: google-services.json — place in android/app/

Never commit these files to version control — add them to .gitignore. For a complete security guide, see our API key security guide.

Step 2: Add the firebase_messaging package

flutter pub add firebase_messaging

Step 3: Configure iOS APNs

iOS push notifications require an APNs key (not a certificate):

  1. Go to Apple Developer Portal → Keys
  2. Create a new key with Apple Push Notifications service (APNs) enabled
  3. Download the .p8 key file
  4. Go to Firebase Console → Project Settings → Cloud Messaging → iOS
  5. Upload the APNs key file
  6. Add the Background Modes capability in Xcode (Remote notifications)

Step 4: Configure Android

Android setup is simpler — FCM works out of the box with the google-services.json config. Add the Firebase messaging service to your AndroidManifest.xml if you need background message handling.

Step 5: Request permissions

import 'package:firebase_messaging/firebase_messaging.dart';

Future<void> requestPermission() async {
  final messaging = FirebaseMessaging.instance;
  final settings = await messaging.requestPermission(
    alert: true,
    badge: true,
    sound: true,
  );
  print('Permission: ${settings.authorizationStatus}');
}

Step 6: Handle incoming messages

Handle foreground messages:

FirebaseMessaging.onMessage.listen((RemoteMessage message) {
  print('Got a message: ${message.notification?.title}');
});

Handle background messages with a top-level function:

@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp();
  print('Background message: ${message.messageId}');
}

Step 7: Get the device token

String? token = await FirebaseMessaging.instance.getToken();
print('FCM Token: $token');

Send this token to your backend server to target this specific device with push notifications.

Common issues

  • No notifications on iOS: Missing APNs key in Firebase, or Background Modes not enabled in Xcode
  • No notifications on Android: Check google-services.json is in android/app/ and the package name matches
  • Notifications work in debug but not release: Check that release builds include the Firebase config files
  • Token is null: Ensure permission was granted and the app has internet access

Before you submit

Push notifications are a core integration that store reviewers may test. Run a free Launch Score check to audit your app's integrations before submitting.

Run your free Launch Score

Frequently asked questions

How do I add push notifications to a Flutter app?

Use the firebase_messaging Flutter package. Set up Firebase project, add google-services.json and GoogleService-Info.plist, configure APNs key for iOS, request permissions, and handle foreground and background messages.

Do I need an Apple Push Notification service (APNs) key for Flutter?

Yes for iOS. Generate an APNs key in the Apple Developer Portal and upload it to Firebase Cloud Messaging settings. Without this, push notifications will not work on iOS.

Are push notifications free with Firebase Cloud Messaging?

Yes, Firebase Cloud Messaging is free for unlimited messages. There is no per-message cost. Firebase handles the delivery infrastructure at no charge.