Ionic 2 – Push Notifications with firebase

Hi Friends,

Hope you are all well. I made a post on Ionic 2 and push notifications long back. This post is an easier way to achieve the same now.

Let’s begin.

A screencast of this post.


The complete code of this post can be found here.

First scaffold out an app using the cli tool.

Then open up this link and create a new app.

Now open up config.xml in your app and copy the widget id in the second line from top. It would look something like com.ionicframework.xxxx

Open your app in firebase console and you would see a screen as shown below.


Click on the Add Firebase to your Android app button.

You would see a screen like this.


Paste the android package name that you took from config.xml here and click on register app.

After registering click on settings (On the app that you registered). You will see a screen like this.


Copy the sender Id from here.

Now install the phonegap-push plugin in your Ionic 2 app using the below command.

Then add the ionic native wrapper for this plugin.

Once this is done open up app.component.ts file and modify it as shown below.

That’s it guys. Don’t forget to add Push as a provider in your app.module.ts file.

Run your app on a device.

From the firebase console click on Notifications in the sidemenu. In the screen that opens up click on New message. You will see a screen like this.


Write your message, choose your app and click on send message. That’s it.

If your app is open, you will see your message in an alert, if not then it would be ‘pushed’ on to your device and you will get a notification.

Please watch the video for a better explanation.

Hope this helped you guys., If you found this helpful, kindly share it with someone else and help them too.

Thanks for reading. Peace.. :)

Liked it? Take a second to support admin on Patreon!
  • Vinit Kumar Goel


    Thanks for this tutorial,

    I am not getting background notification. do i need to change anything?


  • Attila Vegh

    Hey Raj,

    Awesome guide :)

    Any idea how to customise the push notifications? Can’t get sound and icon on the push :(

    android: {
    senderID: ‘937848398327’,
    icon: ‘icon’,
    sound: true,
    vibrate: true,
    forceShow: true

    • Could you please refer to my new posts on push notifications with firebase.. (Kindly watch the videos..) Thanks..

  • Ravi Sojitra

    I followed this article for push notification on device with firebase.
    i copied the same code.
    But it’s always throwing error saying “Cannot read property ‘applicationServerKey’ of undefined”
    How to solve this issue?

  • Dimitri Podoliev

    Hi! Another great tutorial, many thanks for your awesome work! I’m trying to make this work on iOS, and I’ve followed your steps, but I still don’t receive Push Notifications on my iPhone. I’m pretty sure I’ve got all setup correctly, the permissions are set, no code errors, but the notifications just don’t arrive on my Phone. Any ideas why? Many thanks!!

  • siva adhithya


  • Vicky Cj

    Hi ..have a doubt.. In anroid device when i run ionic –prod mode.. it is throwing error plus plugin is not installed,, but in dev mode its working u know why?


    Thanks a lot for this tutorial,it works well…but it does not work for multiple users,i installed the same app on another device and when i am sending the message,i am receiving notification on my device and not the other device with same app.


      The issue has been resolved..,

  • Tarun Narula


    I Followed the same procedure as described above, But this is not working in IOS
    Is there any requirement to use this in IOS

    Thanks in Advance

  • Tushar

    It’s very good tutorials…. awesome bro…
    Could we use this code in ios also ??

  • Ye Chenchao

    Thanks a lot, but this solution only works for Android.

  • Raj Prethive

    Hey Raja,

    I was trying to use push notification with steps you have mentioned. Once I open the app I am able to see Device registered alert. But when I try to send notification from Firebase I am unable to see any success or error message.

    Also I am getting device registered alert every time I open my app.

    Kindly help me out.


  • lalitha peri

    how can i send chat push notifications from one app to another app in different android phones

  • Raessa Fathul Alim

    dont forget to add Push on provider app.module.ts ..

  • Thiago Adriano

    Good tutorial 😉