Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Messaging Ignoring APNS key

I'm trying to send a notification to my device using the apns key as described here: https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig.

The push notification does arrive, but the title is not overridden. When I omit the notification key, the notification is only send (in the background) when I add the content_available: true option.

This is what my body looks like:

{
    "to" : <TOKEN>,
    "apns" : {
        "payload" : {
            "aps" : {
                "alert" : "Does not work",
                "badge" : 1,
                "sound" : "bingbong.aiff"
            }
        }
    } 
    "notification" : { 
        "body" : "Works" 
    }
}

Whatever combination I try, it looks like Firebase is ignoring the apns key. What am I doing wrong?

like image 315
Jorn van Dijk Avatar asked Feb 18 '26 02:02

Jorn van Dijk


1 Answers

You are using legacy API for sending push notifications (not V1). Legacy API doesn't support extra keys like Android or APNs.

So you have two options here:

  1. Keep using legacy API, here's protocol description for it: https://firebase.google.com/docs/cloud-messaging/http-server-ref Keep in mind you'll not be able to use specific Android or APNs keys.
  2. Move to API v1. It lets you use all keys but it requires setting up server for OAuth2. https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig
like image 124
Александр Бабич Avatar answered Feb 20 '26 21:02

Александр Бабич



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!