Push Notifications Body JSON Structure

So I’m a bit confused.

Google has this documentation here and here

In the Fuse documentation for Push Notifications here it says to nest alert inside notification, however, there is no reference to this alert parameter in the google docs above.

I may just be missing something, or misunderstanding what is going on, but I’d like some clarification on this.

More succinctly, as guided by the google docs, when I send this:

"notification" : {
    "body" : "great match!",
    "title" : "Portugal vs. Denmark"
"data" : {
    "Nick" : "Mario",
    "Room" : "PortugalVSDenmark"

it does not work. No notification in the android notification bar, and no data makes it into the app.

But the following makes it to the android notification bar, and the root level title and body are available in the app:

data: {
    notification: {
        alert: {
            body: "from MyApp",
            title: "New Message"
    title: messageTitle,
    body: message

Can anyone explain this?


I’m a bit confused too. :slight_smile:

  • I tried the fuse example (https://www.fusetools.com/learn/guides/push-notifications-android) and I received following message. No notification in the android notification bar, and no data makes it into the app.

  • Applications can not get the message when in the background. When the application to the foreground then falls message to the console.

Console Log
Received Push Notification: {"collapse_key":"do_not_collapse","notification":"{\"alert\":{\"title\":\"Well would ya look at that!\",\"body\":\"Hello from some other app\"}}","payload":"anything you like"}

Hi Levi & Onur, thanks for posting on this. Hopefully I can clear a few things up.

Where possible we like to unify API between the various platforms, iOS is very ridgid and so we pretty much have to take what we are given there, however with android we have much more control (at the expense of some mad apis :p) this let’s us unify things a little.

On android we implement the GcmListenerService so fuse can see the notification as it arrives. We then check to see if the app is started and in the foreground, if so we deliver the message straight to the app and if not we raise the notification.

As you have seen as we unpack the message we chose to make the message format the same as we were forced to use on iOS. I had hoped this would simplify things a little for people but maybe this is not. Would you say this makes it more difficult to work with your exisiting tools or is it just unfamiliarity? I’d love to hear your thoughts on this as whilst I naturally want to simplify things I doubt I have had nearly as much hands-on experience with the backends as you folks.

So the TLDR is yes, our message format is a little different from the google defaults due to a desire for unification.

@Onur: It’s a bummer that this isnt working for you. I have test devices here which show Push Notifications working both in the background and also when the app is fully closed. I’d be really grateful if you could send me your test project, phone details (phone & OS version) and any logs you have handy. It would be great to squash any devices specific bugs we can.

Once again, thanks both of you

Thanks for the update on this @Chris Bagley!

From my perspective, I’d love it if there were an android: and ios: object nested in there (optional of course) and I could just use that, since I’m familiar with the requirements for each.

Then, for those that are unfamiliar, they can use the data: object.

Would that be doable?

Thanks again!

Hi Chris,

Thank you for your interest.

if you could send me your test project, phone details (phone & OS version) and any logs you have handy. It would be great to squash any devices specific bugs we can.

Your e-mail address could you give?

Onur Baran, you can upload your files to https://www.dropbox.com/request/ZgndLtJQm5eGzG9cicGK, then it can only be accessed by the Fuse team.

Levi, interesting idea. I’ll bring it up next time we do an api review on this feature. Thanks!


@fuseTeam I want to start by apologizing. I tried to send the messages with code examples and worked in the following shortcomings.

  • Notification message quiet sounds.
  • If the message is longer cannot be displayed fully.

Hi Onur, no worries, glad to hear it’s closer to working now.

The notification not playing sound is a known issue and should be fixed in the next release.

I will open a ticket to test long messages. There may be a limit on message length (there is for payload) but it should be long enough for this kind of thing. How many characters long was the message that caused the problem?

Hi Chris,

I sent messages and screenshots you will see below. The length of the notification message body 445 characters. But the number of characters that are shown on the screen 41. Click on this sentence for the screenshot.

This other issue I want to ask: As of the moment we can only use, title and body? Isn’t it? If it is right to support other parameters? Is there in your plans?

message format

            {title: "Test", body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}

Onur, thanks for this it shows the problem perfectly. Looks like we need to support BigStyle on android. I have raised a ticket for that internally and we will post here with developments. Naturally we will want to make sure we can provide something similar on ios for consitancy, or find some scheme that gives bigstyle automatically with messages over a certain length…some research is needed :slight_smile:

We defintely have plans to expand the supported parameters. At the very least custom sounds and image are things that I have wanted. How about you?

Thank you Chris. I think it would be enough to support the GCM parameters. It details the connections available.

I congratulate you again for a successful project. Glad to see that I made the right decision to choose you.

I find this alert attribute confusing. Had to migrate the whole Amazon SNS infracstructure to this.

I have the same problem like Onur Baran. I recieve the push notification when my android app is on focus, but when my android app is in background I did not recieve push notification.

I set up fuse like in the example (https://www.fusetools.com/docs/fuse/pushnotifications/push) with Firebase Cloud Messaging (FCM) and I received following message when the android app is on focus. No notification if android app is in background.

How to trigger push notification when the android application is in background ?

If the notifications are delivered when the app is in foreground, then you need to check if the structure of your JSON payload is correct. Specifically, it needs to contain the "alert" element with title and body for the notification to be added to the notification tray. Otherwise it will be “silent”, and only delivered to the app when the app comes in foreground.

Just a little side note that you may want to consider migrating to Fuse.Firebase notifications & Fuse.APNS at some point. Google has gone all in on firebase and so I dont know how long GCM will be supported. Fuse.APNS & Firebase.Notifications were made to work together and the api is very similar to that of Fuse.PushNotifications.

You can find an example of using them together here

Tnx a lot. I solve my problem with inserting element “alert” with title and body like Uldis said before. If a json paramater that is passed in a post api for sending notification https://fcm.googleapis.com/fcm/send does not have “alert” element with title and body, the noticication will not be shown if the application is in background. This is example of valid json parameter that is passed on this api and with this structure the notification will be recieved no matter tha application is in background or not…

{ “data”: {
“notification”: {
“alert”: {
“title”: “Push notification title”,
“body”: “Push notification body”,
“message”: “Push notification message”
“to” : “Reg Id from phone…”

I have one more question. When I have more than one notificiation in the notification status bar and when I clicked on some, I want to know on which one I have clicked. How to achieve that, which trigger I need to create for that ?

There is no particular trigger for that. See the example in this section of docs.

The payload argument in push.on("receivedMessage", function(payload) { receives the whole JSON object that you sent. So if you, for example, included a unique ID as a property in the payload, that could be your way to identify a particular push message.

But when I have, for example, 3 unreaded notifications on notification status bar, the
push.on(“receivedMessage”, function(payload) {} recieves all 3 notifications at the same time if I clicked anyone of them three. When I click on one/first notification, all three messages are recieved. Then when I clicked on the second notification, nothing happens be cause all notifications were recieved before when I clicked on first notifications.

How to trigger the event when I click on the second or third notification in the notification status bar, after previously I have clicked on first notification and all three notification were recieved in push.on(“receivedMessage”, function(payload) {} ?