Ionic3.9 onNotification not triggered when app is in foreground iOS?

Hi Team,
I have implemented push notification its working properly android in both foreground / background state and but in IOS onNotification doesn’t trigger when the app is in foreground or background but its working only if app is killed only.
team can you please me why onNotification not fire in foreground?

  this.fcm.onNotification().subscribe(data => {
  if(data.wasTapped){
    console.log(data.wasTapped);
       //redirectPageViaNotificationType for redirect page...
       this.redirectPageViaNotificationType(data);
  }  else {
      //Notification was received in foreground. Maybe the user needs to be notified
        // if application open, show
      let confirmAlert = this.alertCtrl.create({
        title: (<any>data).title,
        message: (<any>data).body,
        buttons: [{
          text: 'Ignore',
          role: 'cancel'
        },{
          text: 'View',
          handler: () => {
              //redirectPageViaNotificationType for redirect page...
            this.redirectPageViaNotificationType(data);
          }
        }]
      });
      confirmAlert.present();
  }
});

Hello @kapil,

I tried to reproduce this on my end. But I was able to get the notification in the foreground, background, and killed state. I am attaching a screenshot of the console log of Xcode. Can you please let me know on which device are you facing this issue?

Warm Regards,

CometChat Pro
Mayur Bhandari

Hi sir,
I have problem in the difference ios devices and different result.
1.Iphone 5s - push notification is received only in background not in foreground but data.wasTapped fire only if app is killed then tap now function works not in foreground.

1.Iphonex - push notification is received only in background not in foreground but data.wasTapped not fire if app is killed then tap notifications.

Sir i have different scenario in different device.plz help me how to fix it.Check below my xcode log sir-

any updates my query?

Hello @kapil
Apologies for a late response.

We are working on a Token based implementation for Push Notification.
You can track the feature request here.

Regards,
Prathamesh

1 Like

Thanks for response sir but I am already using token based implementation

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.