Add Push Notification in Flutter App via FireBase

Add Push Notification in Flutter App via FireBase

FireBase Segment

  1. Create a Firebase account
  2. Go to Firebase Console.
  3. Tap  Add Project for the new project.
  4. Enter the details of your project and tap Create Project.
  5. Click Continue. FireBase Segment

Add your App To Firebase Project

  1. Tap Android device.
  2. Tap android > app > build.gradle.
  3. Copy the applicationId under defaultconfig.Add your App To Firebase Project
  4. Then paste the ID on the Android Package name.
  5. Then tap Register App.
  6. Now Download google-services.json.Add Firebase to your Android app
  7. Copy the Google-services.json file and then paste it into android > app > src.Google-services.json

Add Firebase SDKAdd Firebase SDK

  1. Copy the 1st link and then go to project > build.gradle.  Paste classpath ‘’ under dependencies.classpath ''
  2. Now copy the 2nd link and then go to project > app-model > build.gradle. paste apply plugin: ‘’  at the end of the code
  3. Then tap next.
  4. Run your flutter project first and then uninstall it.
  5. Again run the flutter App.
  6. Finally, you receive a Flutter Notification window.Flutter Notification window
  7. Here you can enter the notification title, text, duration, and tap review.

Review message

8. Finally, tap Publish.

Flutter Segment

First Install the package

  1. After creating a new flutter document move to pubspec.yaml file
  2. Find Dependencies and then add the package name.

Note: you should add under cupertino_icons: ^0.1.2



3. Tap Package get at the top right corner.

Import the package

  1. Import the package under the basic package
import 'package:firebase_messaging/firebase_messaging.dart';

2. Given coding is to  Configure your notification.


    onMessage: (Map<String, dynamic> message) {

      print('on message $message');


    onResume: (Map<String, dynamic> message) {

      print('on resume $message');


    onLaunch: (Map<String, dynamic> message) {

      print('on launch $message');



3. Given coding is to set Notification alert, and sound.


        const IosNotificationSettings(sound: true, badge: true, alert: true));

    firebaseMessaging.getToken().then((token) {




4. Tokens are one of the important concepts for firebase notification

firebaseMessaging.getToken().then((token) {



Output:firebase notification