Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does firebase set apns-push-type header automatically?

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.

like image 980
Nominalista Avatar asked Sep 25 '19 15:09

Nominalista


People also ask

Does Firebase have push notifications?

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.

How does Firebase push work?

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.

What is difference between APNs and FCM?

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.


1 Answers

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.

like image 154
Matt Kandler Avatar answered Sep 20 '22 06:09

Matt Kandler