Skip to content
This repository was archived by the owner on Feb 7, 2019. It is now read-only.
This repository was archived by the owner on Feb 7, 2019. It is now read-only.

JSON Error on Android in Foreground #121

Description

@nraboy

Hey,

I'm thinking this is a bug, but I'm not truly sure since this is my first time dabbling with push notifications.

On Android, while in the foreground, I get this error during the onMessageReceived event:

W/System.err( 2830): org.json.JSONException: No value for message
W/System.err( 2830): 	at org.json.JSONObject.get(JSONObject.java:389)
W/System.err( 2830): 	at org.json.JSONObject.getString(JSONObject.java:550)

My onMessageReceived looks like this:

notificationCallbackAndroid: (message, data, notification) => {
    console.log("MESSAGE: " + JSON.stringify(message));
    console.log("DATA: " + JSON.stringify(data));
}

While in the foreground, the message is always null, but data contains some actual data. The data parameter contains the following:

{
    "foreground": true,
    "custom-key1": "custom-value1",
    "custom-key2": "custom-value2"
}

It contains all my custom key-value pairs, but not the actual message that was sent. For clarity, I am using FCM which I believe is the only option now, but honestly I'm not sure.

I've confirmed that in the background, I do in fact receive a notification in the tray. However, it is still useful to receive the message in the foreground.

Please let me know.

NativeScript 2.5.4
Android 5.1.1
macOS Sierra

Thanks,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions