I have an app developed with Ionic 6, Capacitor and Angular. In the Push Notifications implementation, pushNotificationReceived event is trigged only when app is in foreground, on iPhone. I am getting the notification when app is in background or in foreground, but this event is NOT triggered when app is in background. Here is the code sample ...
await PushNotifications.addListener('pushNotificationReceived', async (notification: PushNotificationSchema) => {
// update the app badge count
const badgeCount = await this.getDeliveredNotifications();
if (!badgeCount || badgeCount == 0) Badge.set({ count: 1 });
else Badge.set({ count: badgeCount });
});
private getDeliveredNotifications = async () => {
const notificationList: DeliveredNotifications = await PushNotifications.getDeliveredNotifications();
console.log('delivered notifications', notificationList);
return notificationList.notifications.length;
}
Can anyone help me with this issue? Not sure why the event is NOT triggered when app is in background. Any help is greatly appreciated. Thanks in advance.
Problem seem to be unique and I did not find anything similar happening to anyone.
Ionic Info ...enter image description here