I'm trying to get push notifications working in a Cordova app I'm working on. They work perfectly in the Android app and they work perfectly in the iOS app when it's in the foreground, but I don't receive any notifications when the app is in the background or terminated.
I have the "Push Notifications" and "Background Modes - Remote notifications" capabilities enabled:
And I'm 100% sure the server has the device token (since push notifications are working in the foreground, and I can see it in the database).
This is how I'm sending the push notification using the firebase-admin node module:
await firebase.messaging().send({
token: userDeviceToken,
data: {foo: 'bar'},
notification: {
title: 'This is a notification title',
body: 'This is a notification body',
},
});
What am I missing?
EDIT:
If I launch the app or bring it to the foreground after it was supposed to receive a notification, it acts like it received an in-app notification. This happens even if I wait several minutes after the notification was sent before launching the app.