Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Pro subscription. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it’s simply the best investment you can make in your development career.

Add Cloud Messaging to Your App Pro

This video was last updated on Aug 30 2022

When receiving notifications your app may be in the foreground, background or terminated. Learn how to react to notifications in each of these states.


Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

The Flutterfire plugin that adds the Cloud Messaging capabilities is called firebase_messaging.

flutter pub add firebase_messaging 
import 'package:firebase_messaging/firebase_messaging.dart'; 
final messaging = FirebaseMessaging.instance; 
Future<void> _handleMessage(RemoteMessage message) async { 
  print('background message title ${message.notification!.title}'); 
  print('background message body ${message.notification!.body}'); 
  print('background data ${}'); 
FirebaseMessaging.onMessage.listen((RemoteMessage message) { 
    print('Message received in the foreground!'); 
    if (message.notification != null) { 
          'Message notification: ${message.notification?.body}');