According to changes in iOS 13 for APNS, silent push notifications require additional header (apns-push-type
).
I use Firebase as a mediator between backend and mobile, and I'm wondering if Firebase sets mentioned header automatically when content-available
property is set to true.
It is already happening in AWS, as mentioned here.
Can I check somehow in iOS if this header was passed to silent push notification?
I've tested on my devices and everything is working after I updated Firebase dependency to the newest version, even in background. But still I don't have any proof how the header looks like.
Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.
Firebase Notifications is a free service that enables user notifications for Android and iOS devices. Through the Firebase console, you can send notifications quickly and easily across platforms with no server coding required.
APNs needs to be used for push messaging when an application is in the background. Hence, FCM uses APNs to deliver messages when the message contains user visible payload, e.g., body, sound etc. FCM also delivers via APNs when content available is set.
After digging around a little bit and checking how some open source projects updated their code, here's an example on how to add apns-push-type
to Firebase Admin Node:
(I'm using multicast, so your solution might differ.)
const message = {
priority: 'high',
sound: 'default',
notification: {
title: 'Message Title',
body: 'Message Body',
},
android: { ... },
apns: {
headers: { // Add these 3 lines
'apns-push-type': 'alert',
},
payload: {
aps: {
badge: 1,
sound: 'default',
},
},
},
tokens: [ ... ],
};
admin.messaging().sendMulticast(message);
I only had a few notifications failing so I haven't been able to fully confirm that the problem is solved yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With