WebAPI/PushAPI: Difference between revisions

Line 131: Line 131:


== Server API ==
== Server API ==
On the server side we're looking at an HTTP interface that accepts a JSON POST
Push Notification Messages are sent to the <tt>url</tt> returned by the Client API <tt>requestURL()</tt> response (<i>NotificationURL</i>). Notification content consist of a JSON block POSTed to the <i>NotificationURL</i>
with these attributes:


* '''messageType''': "notification". Mandatory
=== Notification JSON Content ===
* '''id''': a server side generated id to identify the notification. Not mandatory.
The Push Notification JSON block consists of the following:
* '''message''': Main body. This could contain a maximum of 1024 bytes. Can be anything that fits in UTF8. Mandatory
* '''signature''': The text message signed with the Private Key that is verified and, if fails, the notification is thrown away and not accepted. Mandatory
* '''ttl''': Maximum time of live of the notification. The server will discard any notification in a maximum time or in the ttl time, whatever first occurs. Not mandatory.
* '''timestamp''': Time when the notification was sent. Not mandatory.
* '''priority''': A priority value, from 1 to 4. 1 should be delivered instantly, and 4 co


* '''messageType''': "notification". <b>Mandatory</b>
* '''message''': Main body. This could contain a maximum of 1024 bytes. Can be anything that fits in UTF8. <b>Mandatory</b>
* '''signature''': The text message signed with the Private Key that is verified and, if fails, the notification is thrown away and not accepted. <b>Mandatory</b>
* '''id''': a server side generated id to identify the notification. <i>Optional</i>.
* '''ttl''': Maximum time of live of the notification. The server will discard any notification in a maximum time or in the ttl time, whatever first occurs. <i>Optional</i>.
* '''timestamp''': Time when the notification was sent. <i>Optional</i>.
* '''priority''': A priority value, from 1 to 4. 1 should be delivered instantly, and 4 will be delivered at the servers discretion. <i>Optional</i>
=== Response ===
HTTP Status Codes in response:
HTTP Status Codes in response:


Line 147: Line 150:
* '''400''': Notification rejected.
* '''400''': Notification rejected.


HTTP Body response:
==== Error Response Body ====
When the notification is rejected, the NotificationURL server will return a JSON block with the following content:


When received a 400, there is a JSON with the status ERROR and a possible reason.
* '''status''': 'ERROR'
* '''reason''': Reason the Status post failed to be handled. <i>Optional</i>
Confirmed users
1,018

edits