By Joao Firmino 0

Hi everyone, in the previous post we talked about "Twitter login with Ionic and Firebase"; assuming you already know a bit about Firebase and how to configure it in your ionic app "Quick Start with Ionic + Firebase", let's see about and how to setup Push Notifications with Firebase Cloud Messaging.

Before everything, make you that you have installed cordova-plugin-fcm plugin by calling the following commands:

cordova plugin add cordova-plugin-fcm
npm install @ionic-native/fcm --save

If you're using Google Login, cordova-plugin-googleplus, you will encounter some errors when building the app for Android. This is because the plugins cordova-plugin-googleplus and cordova-plugin-fcm - will have conflicting issues with the Android libraries used. To solve this, we will manually override the library versions used by the plugins.

Open platforms/android/build.gradle

  • Add in dependencies

  • Set Android and Firebase libraries version to 10.2.0.

  • Add plugin to the end of build.gradle.

buildscript {
    repositories {
        maven {
            url ""

    // Switch the Android Gradle plugin version requirement depending on the
    // installed version of Gradle. This dependency is documented at
    // and
    dependencies {
        classpath ''
        classpath ''

		//Set Android and Firebase libraries version to 10.2.0
		dependencies {
		    compile fileTree(dir: 'libs', include: '*.jar')
		    debugCompile(project(path: "CordovaLib", configuration: "debug"))
		    releaseCompile(project(path: "CordovaLib", configuration: "release"))
		    compile ""
		    compile ""
		    compile ""
		    compile ""
		    compile ""
		    compile ""

		//Add plugin to the end of build.gradle
		apply plugin: ''

Open platforms/android/cordova-plugin-fcm/{project}-FCMPlugin.gradle, and comment out apply plugin:

// apply plugin: ''
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
// apply plugin:

Open platforms/android/, and set library versions to 10.2.0

If you plan on sending Push Notifications to iOS apps. You have to create an APN (Apple Push Notification) Key and configure your project to send Push Notifications in Xcode. Firebase did a great job at explaining how to Configure Apple Push Notifications with FCM in here ->

After you have your APN Auth Key, head over to Firebase Console ► Settings ► Cloud Messaging, and upload your key under iOS app configuration.


If you plan on sending Push Notifications to Android apps, Make sure that you have added the Android platform on Firebase and have generated a google-services.json file, placed on the root of your project. (You may refer to Facebook Login or Google Login section above where an Android platform is added on Firebase).

Finally, take note of your Server key and set it on your configs file, Ex:. src/environment/environment.ts

export const gcmKey = 'AAABBvE9kDCs:APA91bH6ZpM_e5JTRSPJQ9GDCRGwiVz_kHIyjQv5yt5vb1IjaPO6E0MnYYPg-LYudhLFjtjhoaW3_UbN5m8Q7wACRqYMaGI_HguvwhXEUN0fCrk22zrwPC5TjsEIo4HRC6O9TGwp6Jf';

Now we have configured with success Push Notifications and ready to use in your Ionic project.

In the next posts, i'll show more detailed how to use better and with practice the Firebase Cloud Messaging.

See Also

fireIonic - Ionic 3 Firebase Starter Kit

Joao Firmino • 58 Articles

View Articles