Foren

Latest 6.2 EE Push portlet concatenates the JSONs sent from the backoffice

thumbnail
Alfonso Crisci, geändert vor 6 Jahren.

Latest 6.2 EE Push portlet concatenates the JSONs sent from the backoffice

Regular Member Beiträge: 136 Beitrittsdatum: 02.04.14 Neueste Beiträge
Hi,

I'm reporting this issue on behalf of one of our EE customers:

Before installation of Liferay Push EE for 6.2 - Version 1.3.2, the push notifications could be tested by sending a message (plain text) from the backoffice: Control Panel > Push Notifications > Configuration > Test > Message.
With the new version, the message can't be in plain text any more; the system sends a message asking for a JSON. Server sends an error message:

ERROR http-bio-8080-exec-20 com.liferay.portal.jsonwebservice.JSONWebServiceServiceAction - org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]

If JSON is used, the server sends a success message for both registered devices (Android and iOS):

20171019T074431.392+0000 DEBUG liferay/push_notification_response-1 com.liferay.pushnotifications.messaging.PushNotificationsResponseMessageListener - {"id":"0:<removed>","succeeded":true,"platform":"android","status":null,"token":"<removed>","javaClass":"com.liferay.pushnotifications.sender.android.AndroidResponse","payload":"{\"payload\":\"JSON text push notification\"}","canonicalRegistrationId":null}
20171019T074431.394+0000 DEBUG liferay/push_notification_response-1 com.liferay.pushnotifications.messaging.PushNotificationsResponseMessageListener - {"id":"8","succeeded":true,"platform":"apple","status":null,"token":"<removed>","javaClass":"com.liferay.pushnotifications.sender.apple.AppleResponse","payload":"{\"aps\":{},\"payload\":\"{\\\"payload\\\":\\\"JSON text push notification\\\"}\"}","resent":false,"expiry":2147483647}</removed></removed></removed>

Hence, even after setting the {"tag":"value,"}, it interprets it as the value, and sets it as {"tag":"["tag":"value"]"}.

Therefore, the current issue is that the latest version of the pushNotifications portlet concatenates the JSONs sent from the backoffice, thus notifications don't reach the devices.
thumbnail
Javier Gamarra, geändert vor 6 Jahren.

RE: Latest 6.2 EE Push portlet concatenates the JSONs sent from the backoff

Expert Beiträge: 348 Beitrittsdatum: 12.02.15 Neueste Beiträge
Answering also here.

About the test tab, now we require a json object, for several reasons:
  • You can send actions/badges for iOS messages, to test them. Previously it was impossible because we only allowed sending the body part of the message
  • It's consistent with the remote and local services, that is the way of sending messages in production. People reported several bugs about the issue because the format required for the test tab and the services was different.


I couldn't reproduce the tag behaviour but I imagine that the issue is that the tag is set as {"payload": ["tag":["value"]]}. Because everything that is not an body, aps or a badge for iOS notifications is going to be sent in the payload object. And because the payload key itself contains several other fields it's quite possible it is sent this way:

{"payload": {"payload": {"tag": "value}}}