2

I have an in house application where I have the criticalAlert option setup within my application. I have confirmed that when I send the following with the pushy application, I am able to get the Critical Alert to work on the iOS application.

The issue is our internal server currently only sends the notifications to the Firebase Cloud Messaging, and I'm not able to configure the raw push payload to play the critical alert on the device.

Here is the example that Apple gave on how the push should look to APNS:

Here is what I send using the pushy app that works on the application:

{
    "aps" : {
        "content_available": true,
        "priority": "high",
        "alert" : "Your message Here",
        "badge" : 1,
        "sound": {
            "critical": 1,
            "name": "alert.wav",
            "volume": 1.0
        },
        "data": {
            "volume": 7,
            "time_to_live": 900,
            "id": 3618,
            "type": "engagement",
            "overrideMessage": "Testing oncall for iOS",
            "case": "Test Case",
            "repeatNumber": 3,
            "customer": "Google"
        }
    }
}

Here is the current payload that we send to FCM and it works with the custom sound, but we really want the critical alert to be working since the push is for an on-call engagement:

{
    "to": "firebaseToken",
    "content_available": true,
    "priority": "high",
    "isCritical": "true",
    "notification": {
        "title": "Title in notification",
        "body": "Body in notification",
        "sound": "alert.wav",
        "badge": "1",
        "subtitle": "subtitle in notification"
    },
    "data": {
        "volume": 7,
        "time_to_live": 900,
        "id": 3618,
        "type": "engagement",
        "overrideMessage": "Testing oncall for iOS",
        "case": "Test Case",
        "repeatNumber": 3,
        "customer": "Google"
    }
}

I have tried a large number of combinations on what to send to FCM but with no luck:

{
        "to": "firebaseToken",
    "apns": {
        "headers": {
                "apns-priority": "10"
            },
            "payload": {
            "aps" : {
                "sound": {
                    "critical": 1,
                    "name": "alert.wav",
                    "volume": 0.5
                },

and

{
    "aps" : {
        "to": "firebaseToken",
        "content_available": true,
        "priority": "high",
        "alert" : "Your message Here",
        "badge" : 1,
        "sound": {
            "critical": 1,
            "name": "alert.wav",
            "volume": 0.5
        },

and

 {
    "to": "firebaseToken",
    "aps" : {
        "sound" : {
            "critical": 1,
            "name": "alert.wav",
            "volume": 1.0
        }
    },
    "notification": {
        "badge": "1",

and

{
    "to": "firebaseToken",
    "isCritical": "true",
    "content_available": true,
        "notification": {
        "badge": "1",
            "sound" : {
                "critical": 1,
                "name": "alert.wav",
                "volume": 1.0
            },

None of them have allowed the sound dictionary to be passed on to FCM.

I have also the the answer here but it doesn't solve my problem. as I require iOS to know that this push notification is critical and have the OS handle it and not my application.

Justin
  • 35
  • 1
  • 7
  • When you say "passed on to FCM", are you using the REST API or the Admin SDK? Can you include the endpoint if you're using REST or the server code if you're using Admin? – Jen Person Apr 15 '19 at 20:42
  • I don't have access to the server code but I am currently using Postman and sending the json payload to https://fcm.googleapis.com/fcm/send If I can get the proper json to send to FCM then I can get the server side changed to match. – Justin Apr 16 '19 at 13:29
  • Did you get it running with legacy http? We also tried all possible combinations - It is NOT working. APNS, though works. But we must use FCM – AndyB Jun 25 '19 at 19:41
  • We can approve Jen's answer below, although I cannot give an upvote because documentation is cleary broken and it is said there that it is working with the legacy http api. It's definitely working with the admin SDK, which is great btw. It's so easy to get push notifications for all platforms running with this lib. – AndyB Jul 04 '19 at 09:26

1 Answers1

2

Before I give the answer to your specific question, I'd like to recommend that you consider using the Admin SDK instead of the REST API if possible. The SDK is available in Node.js, Java, python, go, and C#. If your server code is written in any of those languages, this is a much simpler way to handle sending messages with FCM. The SDK handles retries and other scenarios you would otherwise have to implement into your code.

As for your question, it's noted in the guides that platform-specific fields only work with the FCM v1 endpoint. To use FCM, your endpoint will look like this:

https://fcm.googleapis.com/v1/projects/[your-project-id]/messages:send

You can see an example of this in the guides. Select REST from the snippet tab to see the example.

Note that the way you authorize sends is different with V1. You can find out more in the guide. If you have trouble with the auth part, I also wrote a blog post about it since it comes up pretty regularly.

Jen Person
  • 7,356
  • 22
  • 30
  • @Jen Person Why is it documented here: https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support This doc clearly describes the http legacy API, still it is NOT working. That's strange. See "notification payload support" -> "sound". It is stated here, that one can use a sound dictionary. We tried every possible combination... – AndyB Jun 25 '19 at 20:13