Push Notifications (FCM)


Hello, first timer here :slight_smile:

I’m struggling to use the Capacitor PushNotification functionality and having issues.

I register the device on FCM using Capacitor PN method successfully, I get a token back, which I store in my users database as well. I verify that when I try to push a new notification through Firebase console, it shows me that 1 device will be getting the notification, which means the device is registered properly.

However although I add a Listener properly (i.e. PushNotifictions.addListener(‘pushNotificationReceived’, (notification: PushNotification) => { //code to process notification }, the listener is never triggered when a push notification is send via the Firebase console.

Full code here:

    PushNotifications.addListener('registrationError', (error: any) => {
      console.log('error on register ' + JSON.stringify(error));
    PushNotifications.addListener('registration', (token: PushNotificationToken) => {
      console.log('token ' + token.value);
      this.user.pnToken = token.value;
      Device.getInfo().then((data) => {
        this.user.devUUID = data.uuid;
        this.user.platform = data.platform;
      }).then(() => {
        PushNotifications.addListener('pushNotificationReceived', (notification: PushNotification) => {
// ----->>> this is never hit 
          console.log('notification ' + JSON.stringify(notification));

(note: I tried reordering the register & addlistener calls the other way round, but behaviour is the same)

Ionic Info:

   ionic (Ionic CLI)             : 4.3.0
   Ionic Framework               : @ionic/angular 4.0.0-beta.15
   @angular-devkit/build-angular : 0.8.6
   @angular-devkit/schematics    : 0.8.6
   @angular/cli                  : 6.2.6
   @ionic/angular-toolkit        : 1.1.0


   capacitor (Capacitor CLI) : 1.0.0-beta.8
   @capacitor/core           : 1.0.0-beta.8

Any idea what is going wrong?



This got solved on Slack.

The problem was the Android emulator, using a real device worked.


How can we use TOPIC based push notification with capacitor push plugin?