3
votes

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?

1
How did it solve for you ? (assuming it worked for you eventually) - Dibzmania
I only used the notification key in the end. - Jorn van Dijk
did anyone find a solution to this? - swalkner

1 Answers

1
votes

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