Enable push notification with Firebase

I need to enable my ionic5 app to receive firebase push notification.

There are 2 different plugins:

  • @awesome-cordova-plugins/firebase
  • @awesome-cordova-plugins/fcm

There is a lot of confusion.

I understood that '@awesome-cordova-plugins/firebase ’ is generic and it enables all firebase features.

"@awesome-cordova-plugins/fcm " instead enables only the messaging features.

it’s correct?

What do you recommend?

I wouldn’t use either. You only need the firebase npm package, no need to go through one that is specific to cordova, capacitor or even ionic.

There is an official Capacitor plugin for push notifications maintained by Ionic - @capacitor/push-notifications.

There is also a good tutorial here as well - Using Push Notifications with Firebase in an Ionic + Angular App.

The advantage of using the Capacitor plugin over the firebase npm package, is that you’ll get native notifications on the device when your app is not running or in the background. If the app is in the foreground, you need to use it in conjunction with Local Notifications if you still want the native notificaiton. Otherwise, you can do an in-app notificaiton.

That’s not true, have you tried it? I get app notifications even if the app isn’t running in the foreground.

I have not tried the firebase package. I assumed it doesn’t hook into native. I stand corrected if it does :slight_smile: Does it work if the app is not running at all?

Well the web api uses service workers so that triggers a notification even if in background

Issue though is that the web only api does not work on iOS. So that imho calls for a capacitor or cordova implementation

i don’t understand which library to use to enable receiving firebase notifications. can you help me?

Tried to use “cordova-plugin-fcm-with-dependecy-updated” but it generate building error on ios

Help me please

The Capacitor plugin includes the Firebase SDK for you on Android. For iOS, you need to include it via CocoaPods. The tutorial walks you through it.

Thanks @twestrick but I use cordova, not Capacitor. Is it the same?

I can’t speak on a Cordova plugin. Have you thought about converting to Capacitor? Capacitor seems to be the future. Many Cordova plugins also work with Capacitor.

I am worried about the migration because the development of the app is almost finished :frowning: