Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS critical alert through FCM

iOS 12 has added critical alerts. The APNS payload has the sound dictionary to support critical alerts. Is there an equivalent sound dictionary support in FCM payload to send FCM notifications to iOS devices.

like image 617
Shashidhar Yamsani Avatar asked Dec 09 '25 17:12

Shashidhar Yamsani


1 Answers

Critical alerts have now been added by firebase.

It can be added to the MessagingPayload like this:

const messagingPayload = {
  token: this.FCMToken,
  notification: {
    ...payload,
  },
  apns: {
    payload: {
      aps: {
        criticalSound: {
          critical: true,
          name: 'default',
          volume: 1.0,
        },
      },
    },
  },
};

return admin.messaging().send(messagingPayload);

The docs can be a little confusing. You have to use messaging().send() and encode the token in the payload, instead of using messaging().sendToDevice().

The payload message is a TokenMessage https://firebase.google.com/docs/reference/admin/node/admin.messaging.TokenMessage

p.s.

You also need to get an entitlement from Apple before you can use critical alerts: https://developer.apple.com/contact/request/notifications-critical-alerts-entitlement/

like image 63
Oscar Hedeby Iversen Avatar answered Dec 12 '25 06:12

Oscar Hedeby Iversen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!