Can't get background push notifications

I have an Ionic Angular (v.6) app and I want to send push notifications to it. I am using Capacitor Push Notifications (v.1.0.9) library. My capacitor version is 3.

When my app is open, I can get notifications from pushNotificationReceived listener. But when my app is killed/background I can’t get any notifications to system tray. I’ve both tried sending push notifications from my API and FireBase console. What am I missing?

await PushNotifications.addListener("registration", (token) => {
	this.h.Toast(this.toastController, token.value);
});

await PushNotifications.addListener("registrationError", (error) => {
	this.h.Toast(this.toastController, error.error);
});

await PushNotifications.addListener("pushNotificationReceived", (notification) => {
	this.h.Toast(this.toastController, JSON.stringify(notification));
});

await PushNotifications.addListener("pushNotificationActionPerformed", (notification) => {
	this.h.Toast(this.toastController, JSON.stringify(notification));
});

PushNotifications.register().then(() => {
	PushNotifications.createChannel({id: "test", name: "test", importance: 5});
});

You can start by updating Capacitor to 6 and Capacitor Push Notifications to 6 too.

Are you sending the notifications with notification or with data payload?
https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages

1 Like

I can’t update to v6 for now, but I am sending notifications with notification, not with data payload. Just want to notify the user when the app is not opened.

I’ve solved it by implementing these two lines:

implementation "com.google.firebase:firebase-iid:21.1.0"
implementation "com.google.firebase:firebase-messaging:22.0.0"