-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Error on parsing GCM json structure #1663
Comments
@clementcontet you are not sending the payload in the correct format. It should look like this:
|
@macdonst, I know the correct format, but as explained in pull #218, some push providers (as the one I use) don't let the choice!
So it would be more coherent to remove completely support for this syntax, or to support it fully. What do you think? |
@clementcontet I'm not really keen on adding more exceptions but I would like to support you. The service you are using is not sending the payload in a typical format. What service is it? |
@macdonst, thanks, I'm using a private service my company is providing me. I don't know if it is based on a commercial product or in-house development. But it serves dozens of apps in our company and I fear that changing the payload format (even if possible) would lead to regression risks for others. To complete the support for this syntax in your plugin, I can try to propose a pull request to fix this, without adding unnecessary case-specific code. |
@clementcontet yeah, sending a PR is the best way forward on this issue. |
+1 on this. The "message" format was actually the early format used by GCM and many push providers coded around this. |
This thread has been automatically locked. |
Expected Behaviour
When I send the following push notif to an Android:
I expect to get the correct title and message.
Actual Behaviour
Yet, for the body of the notif, I get {"title": "Title","message" : "Message"} instead of just Message
Analysis
Digging in the code, the issue is that the plugin accept "message" as the json node for payload content (apparently since pull #218).
See:
But later, the key for the body of the notif is normalized to the same string "message".
See:
And finally, in
replaceKey
method, the body of my notif with the key "message" get replaced with the whole payload (with the same key "message").Is there a point to this last
replaceKey
method call? (as all previously written key/values have already been normalized/localized)Reproduce Scenario
Steps to Reproduce
Send this payload to an Android
Platform and Version
Android 6.0.1
What device vendor
Nexus5
Cordova CLI version and cordova platform version
Plugin version
Sample Push Data Payload
Logs taken while reproducing problem
04-03 17:02:16.016 20441-27607/? D/PushPlugin_GCMIntentService: onMessage - from: 520313199651
04-03 17:02:16.017 20441-27607/? D/PushPlugin_GCMIntentService: normalize extras
04-03 17:02:16.017 20441-27607/? D/PushPlugin_GCMIntentService: key = google.sent_time
04-03 17:02:16.017 20441-27607/? D/PushPlugin_GCMIntentService: replace key google.sent_time with google.sent_time
04-03 17:02:16.018 20441-27607/? D/PushPlugin_GCMIntentService: key = EmbeddedMessageId
04-03 17:02:16.018 20441-27607/? D/PushPlugin_GCMIntentService: replace key EmbeddedMessageId with EmbeddedMessageId
04-03 17:02:16.018 20441-27607/? D/PushPlugin_GCMIntentService: key = google.message_id
04-03 17:02:16.018 20441-27607/? D/PushPlugin_GCMIntentService: replace key google.message_id with google.message_id
04-03 17:02:16.018 20441-27607/? D/PushPlugin_GCMIntentService: key = message
04-03 17:02:16.019 20441-27607/? D/PushPlugin_GCMIntentService: extracting nested message data from key = message
04-03 17:02:16.020 20441-27607/? D/PushPlugin_GCMIntentService: key = data/title
04-03 17:02:16.021 20441-27607/? D/PushPlugin_GCMIntentService: no locale found for key = title, error Value title of type java.lang.String cannot be converted to JSONObject
04-03 17:02:16.021 20441-27607/? D/PushPlugin_GCMIntentService: key = data/message
04-03 17:02:16.021 20441-27607/? D/PushPlugin_GCMIntentService: no locale found for key = message, error Value Message of type java.lang.String cannot be converted to JSONObject
04-03 17:02:16.021 20441-27607/? D/PushPlugin_GCMIntentService: replace key message with message
04-03 17:02:16.022 20441-27607/? D/PushPlugin_GCMIntentService: no locale found for key = message, error No value for locKey
04-03 17:02:16.022 20441-27607/? D/PushPlugin_GCMIntentService: background
04-03 17:02:16.023 20441-27607/? D/PushPlugin_GCMIntentService: message =[{"title":"title","message":"Message"}]
04-03 17:02:16.023 20441-27607/? D/PushPlugin_GCMIntentService: title =[title]
04-03 17:02:16.024 20441-27607/? D/PushPlugin_GCMIntentService: contentAvailable =[null]
04-03 17:02:16.024 20441-27607/? D/PushPlugin_GCMIntentService: forceStart =[null]
04-03 17:02:16.024 20441-27607/? D/PushPlugin_GCMIntentService: create notification
04-03 17:02:16.026 20441-27607/? E/PushPlugin_GCMIntentService: Number format exception - Error parsing notId: Invalid int: "null"
04-03 17:02:16.063 20441-27607/? D/PushPlugin_GCMIntentService: stored icon=push
04-03 17:02:16.065 20441-27607/? D/PushPlugin_GCMIntentService: stored iconColor=#ff7900
04-03 17:02:16.065 20441-27607/? D/PushPlugin_GCMIntentService: stored sound=true
04-03 17:02:16.066 20441-27607/? D/PushPlugin_GCMIntentService: stored vibrate=true
04-03 17:02:16.068 20441-27607/? D/PushPlugin_GCMIntentService: using icon from plugin options
04-03 17:02:16.079 20441-27607/? D/PushPlugin_GCMIntentService: create actions: with in-line
The text was updated successfully, but these errors were encountered: