Receive Push messages

Receive incoming Push messages from your subscribers.

We have covered in detail how to Send Push notifications over an API. When it comes to the reception of incoming messages from your subscribers you can choose between two basic methods:

  • HTTP forward method - allows you to receive incoming messages from your subscribers in real time
  • Pull method - allows you to fetch new messages from Infobip’s server over an API whenever you want

Incoming messages setup

Before you can start receiving messages you need to configure for incoming messages. You can find instructions on how to set up each scenario in the Configuration documentation. It’s up to you which method to use, depending on your use case.

HTTP forward method

If you wish to receive incoming messages in real-time you should use this method.

In order to receive forwarded incoming messages, you will have to set up a unique web address on your own web server able to receive a POST request. Every message we receive from your subscriber will be forwarded to the URL you provided in the Action setup.

Example of a forwarded message:

{
  "results": [
    {
      "messageId": "1561984815238926404",
      "pairedMessageId": "1234984815238926403",
      "from": "69827EDB-A806-4AF6-A7F6-98298EAA4F14",
      "subscriberId":"123",
      "to": "233623e3c860b49ec69a464834343481-8bj4el4a-256d-23fd-56ad-b5bc3d568b53",
      "applicationCode": "233623e3c860b49ec69a464834343481-8bj4el4a-256d-23fd-56ad-b5bc3d568b53",
      "receivedAt": "2017-01-05T12:47:56.221+0000",
      "callbackData": "callbackData",
      "text": "KEYWORD text",
      "cleanText": "text",
      "keyword": "KEYWORD",
      "customPayload":{
        "key1":1,
        "key2":2
      }
    }
  ],
  "messageCount": 1,
  "pendingMessageCount": 0
}	
  

Pull method

All messages received from your subscribers will be received on the Infobip platform and will be there until you decide to access them. Accessing them is pretty much straightforward. All you need to do is make a simple API call which will return the received messages.

Request example:

GET /push/1/inbox/reports HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Accept: application/json	
  

Response:

{
  "results": [
    {
      "messageId": "1561984815238926404",
      "pairedMessageId": "1234984815238926403",
      "from": "69827EDB-A806-4AF6-A7F6-98298EAA4F14",
      "subscriberId":"123",
      "to": "233623e3c860b49ec69a464834343481-8bj4el4a-256d-23fd-56ad-b5bc3d568b53",
      "applicationCode": "233623e3c860b49ec69a464834343481-8bj4el4a-256d-23fd-56ad-b5bc3d568b53",
      "receivedAt": "2017-01-05T12:47:56.221+0000",
      "callbackData": "callbackData",
      "text": "KEYWORD text",
      "cleanText": "text",
      "keyword": "KEYWORD",
      "customPayload":{
        "key1":1,
        "key2":2
      }
    }
  ],
  "messageCount": 1,
  "pendingMessageCount": 0
}	
  

Important

All received messages can be pulled only once! Once a certain message has been pulled by this method, it will not be available in the next API call. This means that every time you make an API call, you will only see the messages received since the last API request you made.