================== Push Notifications ================== .. contents:: List of available sections :local: .. _store_token: Store Token ----------- | Token is stored through Firebase realtime database. | You should use this path for store token: **DOMAIN/jabbers/ADDRESS/firebaseToken/TOKEN**. You can find documentation in this link: https://firebase.google.com/docs/database/. Some characters should be replaced by: - **#** with **"__hash__** - **.** with **__dot__** - **$** with **__dollar__** Token record should have these values: +-------------------------+-----------------------------------+---------------------------------------------+ | **Key** | **Type** | **Description** | +=========================+===================================+=============================================+ | os | String | This value is always **ANDROID** or **IOS** | +-------------------------+-----------------------------------+---------------------------------------------+ | date | String | XMPP date format (yyyy-MM-dd'T'HH:mm:ssZ) | +-------------------------+-----------------------------------+---------------------------------------------+ | appVersion | String | App Version name | +-------------------------+-----------------------------------+---------------------------------------------+ **Example:** **Path**: liam/jabbers/3489543934/firebaseToken/jd3n-dj3-fj3-9gj-3jdwdnini23d3n-j3d23dnd **Values** .. code-block:: json { "os": "ANDROID", "date": "2018-05-06 10:23:44", "appVersion": "1.1", } .. _push_message_payload: Push Message Payload -------------------- The push message is is contained inside notification's payload: Push message payload structure: +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | **Type** | **Parameter name** | **Required** | **Description** | +=============+===========================+==============+============================================================================+ | Boolean | requestReceipt | true | Request receipt of message | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | text | true | Generic text description | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | type | true | Message type | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | payload | false | Payload of message, same as xmpp message | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | serverId | true | Server id of message | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | senderName | true | Name of sender | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | senderAddress | true | Address of sender | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | channelType | true | Type of channel | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | channelName | true | Name of channel | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | channelAddress | true | Address of channel | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | Date | sendDate | true | Message send date | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | Date | receiveDate | false | (it’s setted by the server when message is received) Message received date | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ **Example:** .. code-block:: json { "channelAddress": "00393465448122", "channelName": "Pierpa Vodafone", "channelType": "CHANNEL_STANDARD", "payload": "{\"text\": \"text message\"}", "requestReceipt": true, "sendDate": "2017-03-07T10:46:52.347Z", "receiveDate": "2017-03-07T10:46:52.347Z", "senderAddress": "00393929210907", "senderName": "M8", "serverId": "1488883612255003939292109078cd57", "text": "Tgh", "type": "CHAT_TEXT" } .. _send_push_notification: Send Push Notification ---------------------- To send push notification client needs to save on Firebase realtime database push message. You can find documentation in this link: https://firebase.google.com/docs/database/. | **Standard Channel** | To send push notification to Standard Channel push message should be saved in this path: | **DOMAIN/notificationStandardRequests/{"sender": "MY_JABBER_ID", "receiver": "JABBER_ID", "payload": "{...}"}** | **Group Channel** | Group channel has two steps; first of all save it on database with all group members through this path: | **DOMAIN/notificationSettings/groupChannels/GROUP_ID/[JABBER_ID1, JABBER_ID2,...]** | This operation should be done every time that there are these actions: adding/removing members. | After that for send notification to the Group channel push message should be saved in this path: | **DOMAIN/notificationGroupRequests/{"sender": "MY_JABBER_ID", "receiver": "GROUP_ID", "payload": "{...}"}** How is shown some parts of the path are dynamics, so they change according to the domain and user. Data to be saved for send push message are the following: +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | **Type** | **Parameter name** | **Required** | **Description** | +=============+===========================+==============+============================================================================+ | String | payload | true | Notification payload as described before | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | sender | true | The account that send the notification | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ | String | receiver | true | The account that receive the notification | +-------------+---------------------------+--------------+----------------------------------------------------------------------------+ Data example: .. code-block:: json { "payload" : "{\n \"channelAddress\": \"00393331486253\",\n \"channelName\": \"Gennaro Amendola\",\n \"channelType\": \"CHANNEL_STANDARD\",\n \"payload\": \"{\\n \\\"text\\\": \\\"Cachi\\\"\\n}\",\n \"requestReceipt\": true,\n \"sendDate\": \"2018-04-05T13:54:39.681Z\",\n \"senderAddress\": \"00393929210907\",\n \"senderName\": \"392 921 0907 ~ Gennaro HTC\",\n \"serverId\": \"15229364796810039392921090743d5b\",\n \"text\": \"Cachi\",\n \"type\": \"chat_text\"\n}", "sender" : "00393374588473", "receiver" : "00393331486253" } .. _silenced_push_notification: Silenced Push Notification -------------------------- To silence push notification client needs to save on Firebase realtime database all JabberIds and GroupIds from which doesn't want receive push notifications. You can find documentation in this link: https://firebase.google.com/docs/database/. | Silenced channels should be saved in this path: | **DOMAIN/notificationSettings/silencedChannels/JABBER_ID/[GROUP_ID1, JABBER_ID1, JABBER_ID2,...]**