Push Notification In Flutter in Background as well as in Foreground Using Firebase

Lakshydeep Vikram
Geek Culture
Published in
4 min readJun 22, 2021

--

In Flutter application, there comes a point where we need to integrate push notification. Though we integrate it successfully, sometime we got issue or app got crashed while sending push notifications when app in not running or is opened in background. So here we will integrate push notification using firebase in flutter which works in all states: foreground, background and even when app is closed(not running). Moreover, if you want to redirect that notification to the certain page in the application after click on push notification, here is link.

Let’s start:)

Notification in Foreground as well as in Background.

Firebase and push notification setup

Step I

  • Create firebase project for your app and add googleservices.json file in the android/app folder.
  • Install firebase_messaging and firebase_core in your flutter project.
firebase_messaging: ^8.0.0-dev.14
firebase_core: any
  • Do the settings for firebase initialization in build.gradle (in both app level and android level) file as usual we did.
  • For push…

--

--

Lakshydeep Vikram
Geek Culture

Software Developer | Google Dev Library Author | Flutter Enthusiast