0

I have found various examples on how to configure the message json for push notifcations on firebase for android and ios. But I have a problem, that not all push messages arrives to my client apps. I have noticed that on different android versions it work in a different way. Some of them, doesn't receive any message, some of them without the configured ringtone, some of them only with the default ringtone and some works fine. On client side I think every thing should be fine. I'am using xamarin forms for that. My message json looks like this. I have read now that I should remove the notification tag but it works then for older androids?

 {
"to": "/topics/MYTOPIC",
"notification": {
    "title": null,
    "body": "test",
    "sound": "de900",
    "content_available": true
},
"priority": "high",
"data": {
    "missionGuid": "",
    "eventGuid": "",
    "messageGuid": "e3ab4c34-125b-4ea7-abf7-3ee8fe1453ce",
    "ric": "199900",
    "title": null,
    "body": "test",
    "priority": "high",
    "sound": "de900"
},
"android": {
    "priority": "high",
    "notification": {
        "title": null,
        "body": "test",
        "sound": "de900",
        "content_available": true
    },
    "data": {
        "missionGuid": "",
        "eventGuid": "",
        "messageGuid": "e3ab4c34-125b-4ea7-abf7-3ee8fe1453ce",
        "ric": "199900",
        "title": null,
        "body": "test",
        "priority": "high",
        "sound": "de900"
    },
},
"apns": {
    "headers": {
        "apns-priority": 10
    },
    "payload": {
        "aps": {
            "alert": {
                "title": null,
                "body": "test"
            },
            "sound": "de900"
        }
    }
}

}

KENdi
  • 7,576
  • 2
  • 16
  • 31
cpiock
  • 1,275
  • 2
  • 17
  • 44
  • The removing of notification block works on 4.4, 5.x, it was tested, about lower versions I don't know. But yes, there are different problems with some devices. For example https://stackoverflow.com/questions/52736782/fcm-push-notification-not-working-when-app-close-in-some-of-the-devices-like-xia – Eugene Babich Apr 05 '19 at 08:24
  • This may be interesting for you https://stackoverflow.com/a/39505298/6055194 https://stackoverflow.com/a/37429495/6055194 – Eugene Babich Apr 05 '19 at 08:33
  • Check this https://stackoverflow.com/a/50737948/5805371 – Yuri Popiv Apr 05 '19 at 08:38

2 Answers2

0

As far as I know, setting "priority": "high" is the only thing you can do to make sure the notifications deliver immediately. If they still can't receive anything, it's probably something on the client's side.

For the ringtone, supposedly, "sound": "WHATEVER" is the supposed to specify the sound, but again, because of the different OEMs and system variations, it could be more consistent to just send a data message and push out the notification yourself upon receiving, but you should know that even that probably won't guarantee either deliver or ringtone.

The fact that on some devices this works fine (hopefully the majority of them), indicates you probably have a correct set up for the configuration, and the best you can do is to handle the notification yourself and maybe have special cases for specific devices.

Jack
  • 5,354
  • 2
  • 29
  • 54
0

Setting the "priority" and "sound" in the notification payload never helped me. The behavior of this was very strange. I decided to use only Data payload and handle both background/foreground messages inside onMessageReceived method and show your custom notifications.

After this I was able to show the notifications with the highest priority, pop-ups and sound.

Read more about Firebase data messages here

Yuri Popiv
  • 519
  • 4
  • 15
  • how can I handle background with on messagereceived. does this not only work for foreground ? – cpiock Apr 05 '19 at 08:45
  • @cpiock Check this sheet https://firebase.google.com/docs/cloud-messaging/android/receive#handling_messages. When use `Data` both foreground and background will trigger `onMessageReceived` – Yuri Popiv Apr 05 '19 at 08:47
  • this means by removing notification tag I can handle my messages with onmessagereceived? oh sounds great – cpiock Apr 05 '19 at 08:54