Messages

Ask tech team
From QuickBlox Developers (API docs, code samples, SDK)
Jump to: navigation, search

Contents

Summary

Employs Amazon EC servers’ power to send thousands of technical and marketing messages to your users. Four channels are supported:

  • Push Notifications – sends iOS, Android, WP, BlackBerry pushes. This is being used for technical notifications, reminders and marketing messages. Also used as IM, enabling you or your users to send direct messages to other users (even if they are offline and not using the app). Can be integrated with other functions within the particular application.
  • Emails – sending e-mails to your users. This is being used for users registration, password reminders, marketing newsletter etc


Features

  • Messages Queue – messages can be either sent instantly or assigned a specific time/date and pushed into a Message Queue which allows to send delayed and recurring messages such as reminders, planned marketing announcements or any planned notifications for the better engagement of the users.
  • Recurring notifications – set up a time interval and the message will be repeated automatically by the server
  • User tags - a feature powered by integration with our Users module, allowing to specify a group of users the message shall be sent to
  • Media attachments (send rich media attachments such as video, audio and location data, including video streaming, powered by our Content module). Not available for emails.

The module setup is configured so that to match your projected requirements (for example: 10 / 100 / 1000 messages per second).

Need to know information

Before start with Messages module please read the following:



Messages API

Messages module provides powerful and simple to use API to subscribe your user base to push & email notifications and send them.

Typical use сases

Send Push Notification from Admin panel

To send message from Admin panel you need to do next steps:
Client side (subscribe to Push Notifications channel):

Admin panel:

  • iOS - upload сertificates; Android - register your Android application, then you need to get the tokens for your google account.
  • Send message using Messages module

Send Push Notification from Application

To send message from client side you need to do next steps:
Client side (subscribe to Push Notifications channel):

Client side (send Push Notifications):

Admin panel:

  • iOS - upload сertificates; Android - register your Android application, then you need to get the tokens for your google account.


Requests and Responses

URL HTTP Verb Supported formats Action Description Success HTTP Status Code
/push_tokens POST
  • xml
  • json
Create push token 201
/push_tokens/:id DELETE
  • xml
  • json
Delete push token 200
/subscriptions POST
  • xml
  • json
Create subscriptions (subscribes) 201
/subscriptions GET
  • xml
  • json
Retrieve subscriptions 200
/subscriptions/:id DELETE
  • xml
  • json
Remove subscription (unsubscribes) 200
/events POST
  • xml
  • json
Create event 201
/events GET
  • xml
  • json
Get events 200
/events/{event_id} PUT
  • xml
  • json
Edit event 200
/events/{event_id} DELETE
  • xml
  • json
Delete event 200
/events/{event_id} GET
  • xml
  • json
Retrieve event by ID 200


Create push token

Create push token (Token for iOS, Registration Id for Android, Uri for Windows Phone). Neеd to get the authorization token with the device parameters (platform, udid)

Parameters

Param Required Type Value Example Description
push_token[environment] Yes Enum development Determine application mode. It allows conveniently separate development and production modes. Allowed values: development, production
push_token [client_identification_sequence] Yes String 144 Identifies client device in 3-rd party service like APNS, GCM, BBPS or MPNS. Initially retrieved from 3-rd service and should be send to QuickBlox to let it send push notifications to the client.
device[platform] Yes String ios, android, windows_phone, blackberry Platform of device, which is the source of API requests to Quickblox
device[udid] Yes String 2343af3433aa3a4fsv UDID (Unique Device identifier) of device, which is the source of API requests to Quickblox. This must be anything sequence which uniquely identify particular device. This is needed to support schema: 1 User - Multiple devices.

Request

curl -X POST \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 0b06980edeca062ebed4f8d402449f84e88fcac4" \
-d "push_token[environment]=production&push_token[client_identification_sequence]=aa557232bc237245ba67686484efab&device[platform]=iOS&device[udid]=5f5930e927660e6e7d8ff0548b3c404a4d16c04f" \
http://api.quickblox.com/push_tokens.xml
curl -X POST \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 17f6a337b0656c9c7e983f9705d79562fc694c0e" \
-H "Content-Type: application/json" \
-d '{"push_token": {"environment": "production", "client_identification_sequence": "aa557232bc237245ba67686484efab",
"device[platform]": "iOS",
"device[udid]": "5f5930e927660e6e7d8ff0548b3c404a4d16c04f"}}' \
http://api.quickblox.com/push_tokens.json

Response

<?xml version="1.0" encoding="UTF-8"?>
<push-token>
  <id type='integer'>
    4
  </id>
  <environment>
    production
  </environment>
  <client-identification-sequence>
http://sn1.notify.live.net/throttledthirdparty/01.00/AAEOfnKUM_SuQa9agDruLiSFAgAAAAADAgAAAAQUZm52OjIzOEQ2NDJDRkI5MEVFMEQ
  </client-identification-sequence>
</push-token>
{
  "push_token": {
    "client_identification_sequence": "aa7115e02fa35f9f8fc1efc4bc14822b73e5bf0b52b205b6ae346ce375eb1bc3",
    "environment": "production",
    "id": 30
  }
}


Delete push token

Delete push token by identifier

Request

curl -X DELETE \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 37f5a3ab41ea96622c3a05d4205e29c7daf00e44" \
http://api.quickblox.com/push_tokens/4.xml
curl -X DELETE \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 37f5a3ab41ea96622c3a05d4205e29c7daf00e44" \
http://api.quickblox.com/push_tokens/5.json

Response

Empty body, status: 200
Status: 200, null


Create subscriptions (subscribes)

Сreate device based subscriptions. The authorization token should contain the device parameters. If the subscription is creating for the windows phone pushes make sure that Microsoft Push Notifications have a status "enabled" in the Web Administration Panel.

Parameters

Param Required Type Value Example Description
notification_channels Yes String apns, gcm, mpns, bbps, email Declare which notification channels could be used to notify user about events. Allowed values: email, apns, gcm, mpns, bbps.

Request

curl -X POST \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 0b06980edeca062ebed4f8d402449f84e88fcac4" \
-d "notification_channels=apns" \
http://api.quickblox.com/subscriptions.xml
curl -X POST \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 17f6a337b0656c9c7e983f9705d79562fc694c0e" \
-d '{"notification_channels": "apns"}' \
http://api.quickblox.com/subscriptions.json

Response

<?xml version="1.0" encoding="UTF-8"?>
<subscriptions type="array">
  <subscription>
    <id type="integer">12</id>
    <notification-channel>
      <name>apns</name>
    </notification-channel>
    <device>
      <udid>3429C429-4C34-5214-8E3C-803AC0CA79ED</udid>
      <platform>
        <name>ios</name>
      </platform>
    </device>
  </subscription>
</subscriptions>
[
  {
    "subscription": {
      "id": 41,
      "notification_channel": {
        "name": "apns"
      },
      "device": {
        "udid": "3h61hw0jvd",
        "platform": {
          "name": "ios"
        }
      }
    }
  }
]


Retrieve subscriptions

Retrieve subscriptions for the device which is specified in the authorization token.

Request

curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 0b06980edeca062ebed4f8d402449f84e88fcac4" \
http://api.quickblox.com/subscriptions.xml
curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: d85042b92eb651c6c4a68ad49a87b985a9ba50e2" \
http://api.quickblox.com/subscriptions.json

Response

<?xml version="1.0" encoding="UTF-8"?>
<subscriptions type="array">
  <subscription>
    <id type="integer">3</id>
    <notification-channel>
      <name>email</name>
    </notification-channel>
    <device>
      <udid>3429C429-4C34-5214-8E3C-803AC0CA79ED</udid>
      <platform>
        <name>ios</name>
      </platform>
    </device>
  </subscription>
  <subscription>
    <id type="integer">9</id>
    <notification-channel>
      <name>gcm</name>
    </notification-channel>
    <device>
      <udid>3429C429-4C34-5214-8E3C-803AC0CA79ED</udid>
      <platform>
        <name>ios</name>
      </platform>
    </device>
  </subscription>
</subscriptions>
[
  {
    "subscription": {
      "id": 40,
      "notification_channel": {
        "name": "email"
      },
      "device": {
        "udid": "3429C429-4C34-5214-8E3C-803AC0CA79ED",
        "platform": {
          "name": "ios"
        }
      }
    }
  },
  {
    "subscription": {
      "id": 41,
      "notification_channel": {
        "name": "apns"
      },
      "device": {
        "udid": "3429C429-4C34-5214-8E3C-803AC0CA79ED",
        "platform": {
          "name": "ios"
        }
      }
    }
  }
]


Remove subscription (unsubscribes)

Remove a subscription by the identifier

Request

curl -X DELETE \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 0b06980edeca062ebed4f8d402449f84e88fcac4" \
http://api.quickblox.com/subscriptions/12.xml
curl -X DELETE \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 0b06980edeca062ebed4f8d402449f84e88fcac4" \
http://api.quickblox.com/subscriptions/13.json

Response

Empty body, status: 200
Status: 200, null


Create event

Create notification event

Parameters

Param Required Type Value Example Description
event[active] Optional Bool true If you want to send specific notification more than once - just edit event & set this field to 'true', Then push will be send immediately, without creating a new one event.

By default: true

event[notification_type] Yes Enum
  • push
  • email
  • push: Push notification
  • email
event[push_type] No Enum
  • apns
  • mpns
  • gcm
  • bbps

Used only if notification_type == push, ignored in other cases

  • If not present - Notification will be delivered to all possible devices for specified users. Each platform will have their own standard format. See Quickblox Standard Push Notifications Formats for more information
  • If specified - Notification will be delivered to specified platform only
event[user][ids] No string 11,25,356,489

Should contain a string of users' ids divided by comas.

event[user][tags][any] No string good,bad,ugly

Should contain a string of tags divided by comas. Recipients (users) must have at least one tag that specified in list.

event[user][tags][all] No string tag1,tag2,tag3

Should contain a string of tags divided by comas. Recipients (users) must exactly have only all tags that specified in list

event[user][tags][exclude] No string tag1,tag2,tag3

Should contain a string of tags divided by comas. Recipients (users) mustn't have tags that specified in list

event[external_user][ids] No string 15,24,367,49

Should contain a string of external users' ids divided by comas.

event[environment] Yes Enum
  • development
  • production

Environment of the notification.

event[message] Yes string
  • Pushes:

event[push_type] not present - should be Base64 encoded text.

event[push_type] specified - should be formatted as described in QuickBlox Push Notifications Formats

  • Email:

Base64 encoded text

event[date]
  • Yes, if the 'event_type' = 'fixed_date' or 'period_date'
Timestamp 11241342343 The date of the event.

If the 'event type'=='fixed_date', the date can not be in the past.

event[end_date]
  • No
Timestamp 31241342343 Date of completion of the event.

Can't be less than the 'date'.

event[period]
  • Yes, if the 'event_type' = 'period_date'
Timestamp 86400 The period of the event in seconds.
Possible values:
  • 86400 (1 day)
  • 604800 (1 week)
  • 2592000 (1 month)
  • 31557600 (1 year)
event[name]

No

String my event The name of the event. Service information. Only for the user.
event[event_type] No Enum
  • one_shot
  • fixed_date
  • period_date

one_shot - a one-time event, which causes by an external object (the value is only valid if the 'date' is not specified)

fixed_date - a one-time event, which occurs at a specified 'date' (the value is valid only if the 'date' is given)

period_date - reusable event that occurs within a given 'period' from the initial 'date' (the value is only valid if the 'period' specified)

By default:

fixed_date, if 'date' is specified

period_date, if 'period' is specified

one_shot, if 'date' is not specified

Request

curl -X POST \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: ba4727bab3aa1d822ac96e12dbdc2b01f0acce7a" \
-d "event[notification_type]=push&
event[push_type]=apns&
event[user][ids]=1,2,3,4,5,6&
event[environment]=development&
event[message]=payload=eyJhcHMiOnsic291bmQiOiJkZWZhdWx0IiwiYWxlcnQiOiJZb3UgaGF2ZSBqdXN0IHJlY2VpdmVkIGEgbmV3IG1lc3NhZ2UgZnJvbSBZdWxpYSBTeWRvcmVua28uIn0sIngiOnsiZGF0YSI6IntcInR5cGVcIjpcIm1lc3NhZ2VcIixcImZyb21fbmFtZVwiOlwiWXVsaWEgU3lkb3JlbmtvXCIsXCJmcm9tX2lkXCI6XCI4NTc1MTFcIixcImZyb21fZmFjZWJvb2tcIjpcIjEwMDAwMDM0OTA4MjYwM1wifSJ9fQ==" \
http://api.quickblox.com/events.xml
curl -X POST \
-H "Content-Type: application/json" \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: ee7db1a695eeb42830498720a7e9d56682472fbd" \
-d '{"event": {"notification_type": "push", "environment": "production", "user": { "ids": "1326"}, "message": "payload=eyJhcHMiOnsic291bmQiOiJkZWZhdWx0IiwiYWxlcnQiOiJZb3UgaGF2ZSBqdXN0IHJlY2VpdmVkIGEgbmV3IG1lc3NhZ2UgZnJvbSBZdWxpYSBTeWRvcmVua28uIn0sIngiOnsiZGF0YSI6IntcInR5cGVcIjpcIm1lc3NhZ2VcIixcImZyb21fbmFtZVwiOlwiWXVsaWEgU3lkb3JlbmtvXCIsXCJmcm9tX2lkXCI6XCI4NTc1MTFcIixcImZyb21fZmFjZWJvb2tcIjpcIjEwMDAwMDM0OTA4MjYwM1wifSJ9fQ==", "push_type": "apns"}}' \
http://api.quickblox.com/events.json

Response

<?xml version="1.0" encoding="UTF-8"?>
<event>
  <active type="boolean">true</active>
  <application-id type="integer">1</application-id>
  <created-at type="datetime">2012-03-02T09:39:55Z</created-at>
  <date type="integer" nil="true"></date>
  <end-date type="integer" nil="true"></end-date>
  <event-type>one_shot</event-type>
  <id type="integer">53</id>
 <message>payload=eyJhcHMiOnsic291bmQiOiJkZWZhdWx0IiwiYWxlcnQiOiJZb3UgaGF2ZSBqdXN0IHJlY2VpdmVkIGEgbmV3IG1lc3NhZ2UgZnJvbSBZdWxpYSBTeWRvcmVua28uIn0sIngiOnsiZGF0YSI6IntcInR5cGVcIjpcIm1lc3NhZ2VcIixcImZyb21fbmFtZVwiOlwiWXVsaWEgU3lkb3JlbmtvXCIsXCJmcm9tX2lkXCI6XCI4NTc1MTFcIixcImZyb21fZmFjZWJvb2tcIjpcIjEwMDAwMDM0OTA4MjYwM1wifSJ9fQ==</message>
  <name nil="true"></name>
  <occured-count type="integer">0</occured-count>
  <updated-at type="datetime">2012-03-02T09:39:55Z</updated-at>
  <user-id type="integer">2</user-id>
  <notification-channel>
    <name>apns</name>
  </notification-channel>
  <subscribers-selector>
    <environment>development</environment>
    <user-ids type='array'>
        <user-id type='integer'>
          1
        </user-id>
        <user-id type='integer'>
          2
        </user-id>
        <user-id type='integer'>
          3
        </user-id>
        <user-id type='integer'>
          4
        </user-id>
        <user-id type='integer'>
          5
        </user-id>
      </user-ids>
  </subscribers-selector>
</event>
{
  "event": {
    "active": true,
    "application_id": 140,
    "created_at": "2012-05-07T12:55:15Z",
    "date": null,
    "end_date": null,
    "event_type": "one_shot",
    "id": 592,
    "message": "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
    "name": null,
    "occured_count": 0,
    "period": null,
    "updated_at": "2012-05-07T12:55:15Z",
    "user_id": 1326,
    "notification_channel": {
      "name": "apns"
    },
    "subscribers_selector": {
      "environment": "production",
      "user_ids":[
             1,2,3,4,5
          ]
    }
  }
}


Get events

Get all events which were created by a user specified in the authorization token

Request

curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 94a8a64512df282b5dbc73d066c105cbd3d6c039" \
http://api.quickblox.com/events.xml
curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: b9c808a7a9d44ca5804f38c43f62d9d0ef8c8020" \
http://api.quickblox.com/events.json

Response

<?xml version='1.0' encoding='UTF-8'?>
<events type="array" current_page="1" per_page="10" total_entries="2">
  <event>
    <active type="boolean">true</active>
    <application-id type="integer">1</application-id>
    <created-at type="datetime">2012-04-03T12:30:05Z</created-at>
    <date type="integer">1333457419</date>
    <end-date type="integer">1335611471</end-date>
    <event-type>one_shot</event-type>
    <id type="integer">9</id>
<message>subject=Tm90aWZpY2F0aW9uIGZyb20gYmxhYmxh&amp;body=YXNkcXdlYWQ=</message>
    <name nil="true"></name>
    <occured-count type="integer">0</occured-count>
    <period type="integer" nil="true"></period>
    <updated-at type="datetime">2012-04-03T12:49:29Z</updated-at>
    <user-id type="integer">4</user-id>
    <notification-channel>
      <name>push</name>
    </notification-channel>
    <subscribers-selector>
      <environment>development</environment>
      <tags-query>
        <all>man</all>
      </tags-query>
      <user-ids type='array'>
        <user-id type='integer'>
          97
        </user-id>
        <user-id type='integer'>
          97
        </user-id>
      </user-ids>
    </subscribers-selector>
  </event>
  ...
</events>
{
  "current_page": 1,
  "per_page": 10,
  "total_entries": 1,
  "items": [
    {
      "event": {
        "active": false,
        "application_id": 2,
        "created_at": "2012-03-21T09:49:03Z",
        "date": null,
        "end_date": null,
        "event_type": "one_shot",
        "id": 290,
        "message": "mpns=PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlmaWNhdGlvbic%2BPHdwOlRvYXN0Pjx3cDpUZXh0MT5JbmNvbWluZyBNZXNzYWdlPC93cDpUZXh0MT48d3A6VGV4dDI%2BdGVzdCBtZXNzYWdlPC93cDpUZXh0Mj48d3A6UGFyYW0%2BL3F1aWNrYmxveC54YW1sPC93cDpQYXJhbT48L3dwOlRvYXN0Pjwvd3A6Tm90aWZpY2F0aW9uPg==%26headers=Q29udGVudC1UeXBlLHRleHQveG1sLENvbnRlbnQtTGVuZ3RoLDIyNiwnWC1Ob3RpZmljYXRpb25DbGFzcywyLFgtV2luZG93c1Bob25lLVRhcmdldCx0b2FzdA==",
        "name": null,
        "occured_count": 1,
        "period": null,
        "updated_at": "2012-03-21T09:49:11Z",
        "user_id": 3,
        "notification_channel": {
          "name": "mpns"
        },
        "subscribers_selector": {
          "environment": "production",
          "tags_query": {
            "all":"man"
          },
          "user_ids":[
             ...
          ]
        }
      }
    }
  ]
}


Edit event

Edit event with ID

Parameters

Param Required Type Value Example Description
event[active] Optional Bool true Marks event as active/inactive
event[message] Optional Base64

payload=eyJhcHMiOnsiYWxlcnQi OiJkZnNkZnNzZGYiLCJiYWRnZSI 6MSwic291bmQiOiJkZWZhdWx0In19

event[date]

Yes, and the possibility of a parameter depends on the 'event_type' value

Timestamp 86400 The date of the event.

If the 'event type'=='fixed_date', the date can not be in the past.

event[period]

Yes, and the possibility of a parameter depends on the 'event_type' value

Timestamp 86400 The period of the event in seconds.
Possible values:
  • 86400 (1 day)
  • 604800 (1 week)
  • 2592000 (1 month)
  • 31557600 (1 year)
event[name]

Optional

String my event The name of the event


Request

curl -X PUT \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 61be07f7fd9071e0eab36ec51cdd68d5e97570c7" \
-d "event[name]=workEvent" \
http://api.quickblox.com/events/320.xml
curl -X PUT \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: d85042b92eb651c6c4a68ad49a87b985a9ba50e2" \
-d '{"event": {"date": "1332327600", "period": "1332414000", "name": "My%20New%20Event"}}' \
http://api.quickblox.com/events/394.json

Response

<?xml version='1.0' encoding='UTF-8'?>
<event>
  <active type='boolean'>
    false
  </active>
  <created-at type='datetime'>
    2012-02-07T15:13:57Z
  </created-at>
  <date type='integer' nil='true'/>
  <end-date type='integer' nil='true'/>
  <event-type>
    one_shot
  </event-type>
  <id type='integer'>
    320
  </id>
<message>payload=eyJhcHMiOnsiYWxlcnQiOiJzeWRvcmVua29feXVsaWEiLCJiYWRnZSI6MCwic291bmQiOiJkZWZh dWx0In19
  </message>
  <name>
    workEvent
  </name>
  <occured-count type='integer'>
    1
  </occured-count>
  <request-action-type>
    optional
  </request-action-type>
  <updated-at type='datetime'>
    2012-02-07T16:36:32Z
  </updated-at>
  <notification-channel>
    <name>
      apns
    </name>
  </notification-channel>
  <subscribers-selector>
    <environment>
      development
    </environment>
  </subscribers-selector>
</event>
{
  "event": {
    "active": false,
    "application_id": 3,
    "created_at": "2012-03-22T13:25:06Z",
    "date": 1332327600,
    "end_date": null,
    "event_type": "one_shot",
    "id": 394,
    "message": "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
    "name": "My New Event",
    "occured_count": 1,
    "period": 1332414000,
    "updated_at": "2012-03-22T16:16:52Z",
    "user_id": 89,
    "notification_channel": {
      "name": "apns"
    },
    "subscribers_selector": {
      "environment": "development"
    }
  }
}


Delete event

Delete event

Request

curl -X DELETE \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 61be07f7fd9071e0eab36ec51cdd68d5e97570c7" \
http://api.quickblox.com/events/320.xml
curl -X DELETE \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 61be07f7fd9071e0eab36ec51cdd68d5e97570c7" \
http://api.quickblox.com/events/320.json

Response

Empty body, status: 200
Status: 200, null


Retrieve event by ID

Retrieve event by the ID. The event specified in the request should belong to the application for which the authorization token has been received

Request

curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: 61be07f7fd9071e0eab36ec51cdd68d5e97570c7" \
http://api.quickblox.com/events/327.xml
curl -X GET \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-H "QB-Token: d85042b92eb651c6c4a68ad49a87b985a9ba50e2" \
http://api.quickblox.com/events/394.json

Response

<?xml version='1.0' encoding='UTF-8'?>
<event>
  <active type='boolean'>
    true
  </active>
  <created-at type='datetime'>
    2012-02-07T15:31:34Z
  </created-at>
  <date type='integer' nil='true'/>
  <end-date type='integer' nil='true'/>
  <event-type>
    one_shot
  </event-type>
  <id type='integer'>
    327
  </id><message>payload=eyJhcHMiOnsiYWxlcnQiOiJzeWRvcmVua29feXVsaWEiLCJiYWRnZSI6MCwic291bmQiOiJkZWZh dWx0In19
  </message>
  <name nil='true'/>
  <occured-count type='integer'>
    0
  </occured-count>
  <period type='integer' nil='true'/>
  <updated-at type='datetime'>
    2012-02-07T15:31:34Z
  </updated-at>
  <notification-channel>
    <name>
      apns
    </name>
  </notification-channel>
  <subscribers-selector>
    <environment>
      development
    </environment>
  </subscribers-selector>
</event>
{
  "event": {
    "active": false,
    "application_id": 3,
    "created_at": "2012-03-22T13:25:06Z",
    "date": 1332327600,
    "end_date": null,
    "event_type": "one_shot",
    "id": 394,
    "message": "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
    "name": "My New Event",
    "occured_count": 1,
    "period": 1332414000,
    "updated_at": "2012-03-22T16:16:52Z",
    "user_id": 89,
    "notification_channel": {
      "name": "apns"
    },
    "subscribers_selector": {
      "environment": "development"
    }
  }
}


Push Notification Formats

Platform based push notification

Platform based push notification will be delivered to specified platform only. To specify platform use event[push_type] parameter with values apns, mpns, gcm or bbps.

With platform based push notification you can use all specified features of particular platform, no restrictions.

General requirements

Message format is a key=value string. Where key is raw text and value - BASE64 encoded and CGI escaped. Each pair should be separated by &
Example: key1=c29tZXZhbHVlMQ==&key2=YW5vdGhlcnZhbHVlMg==&key3=dGhpcmRleGFtcGxl
Important! & should be escaped by %26

iOS

Meets Apple requirements. See Apple developer portal for more detailed information.

Example:
JSON payload:

{
    "aps" : {
        "alert" : "You got your emails.",
        "badge" : 9,
        "sound" : "bingbong.aiff"
    },
    "acme1" : "bar",
    "acme2" : 42
}

Base64 Encoded data:
ew0KICAgICJhcHMiIDogew0KICAgICAgICAiYWxlcnQiIDogIllvdSBnb3QgeW91ciBlbWFpbHMuIiwNCiAgICAgICAgImJhZ
GdlIiA6IDksDQogICAgICAgICJzb3VuZCIgOiAiYmluZ2JvbmcuYWlmZiINCiAgICB9LA0KICAgICJhY21lMSIgOiAiYmFyIiwNCiAg
ICAiYWNtZTIiIDogNDINCn0=

Final message (for iOS pushes you should add payload= before message):
event[message]=payload=ew0KICAgICJhcHMiIDogew0KICAgICAgICAiYWxlcnQiIDogIllvdSBnb3QgeW91ciBlbWFpbHMuIiwNCiAgICAgICAg
ImJhZGdlIiA6IDksDQogICAgICAgICJzb3VuZCIgOiAiYmluZ2JvbmcuYWlmZiINCiAgICB9LA0KICAgICJhY21lMSIgOiAiYmFyIiwNCi
AgICAiYWNtZTIiIDogNDINCn0=

Android

Meets Google GCM requirements. See Android developer portal for more detailed information.

Message format is a data.key1=value1&...&data.keyN=valueN
Values should be CGI-escaped before Base64 encoding.
Required field collapse_key is added automatically before sending and contains value "event<ID>"

data.message key is required and should be 1st.

Example:
Plain message:
data.message=I love M&M's! Especially red one!

CGI-escaped:
data.message=I+love+M%26M%27s%21+Especially+red+one%21

Base64-encoded:
event[message]=data.message=SStsb3ZlK00lMjZNJTI3cyUyMStFc3BlY2lhbGx5K3JlZCtvbmUlMjE=

Windows Phone

Meets Microsoft requirements. See MSDN portal for more detailed information.

Example:
Body:

<?xml version='1.0' encoding='utf-8'?>
<wp:Notification xmlns:wp='WPNotification'>
  <wp:Toast>
    <wp:Text1>Incoming Message</wp:Text1>
    <wp:Text2>ping</wp:Text2>
    <wp:Param>/quickblox.xaml</wp:Param>
  </wp:Toast>
</wp:Notification>


Headers should be written in a string as key,value separated by comas.
Headers: Content-Type,text/xml,Content-Length,226,X-NotificationClass,2,X-WindowsPhone-Target,toast

Base64 Encoded data:
PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlm
aWNhdGlvbic=PHdwOlRvYXN0Pjx3cDpUZXh0MT5JbmNvbWluZyBNZXNzYWdlPC93cDpUZXh0MT48d3A6VGV4dDI=cGluZzwvd3A6VGV
4dDI=PHdwOlBhcmFtPi9xdWlja2Jsb3gueGFtbDwvd3A6UGFyYW0=PC93cDpUb2FzdD48L3dwOk5vdGlmaWNhdGlvbj4=&headers=Q
29udGVudC1UeXBlLHRleHQveG1sLENvbnRlbnQtTGVuZ3RoLDIxOCxYLU5vdGlmaWNhdGlvbkNsYXNzLDIsWC1XaW5kb3dzUGhvbmUtVGFyZ
2V0LHRvYXN0

Final message (for WP pushes you should add mpns= before message):
event[message]=mpns=PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlm
aWNhdGlvbic=PHdwOlRvYXN0Pjx3cDpUZXh0MT5JbmNvbWluZyBNZXNzYWdlPC93cDpUZXh0MT48d3A6VGV4dDI=cGluZzwvd3A6VGV
4dDI=PHdwOlBhcmFtPi9xdWlja2Jsb3gueGFtbDwvd3A6UGFyYW0=PC93cDpUb2FzdD48L3dwOk5vdGlmaWNhdGlvbj4=&headers=Q
29udGVudC1UeXBlLHRleHQveG1sLENvbnRlbnQtTGVuZ3RoLDIxOCxYLU5vdGlmaWNhdGlvbkNsYXNzLDIsWC1XaW5kb3dzUGhvbmUtVGFyZ
2V0LHRvYXN0

Blackberry

Meets Blackberry requirements. See Blackberry developer portal for more detailed information.

Example Base64 Encoded data:
PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlm
aWNhdGlvbic=PHdwOlRvYXN0Pjx3cDpUZXh0M5JbmNvbWluZyBNZXNzYWdlPC93cDpZXh0MT48d3A6VGV4dDI=cGluZzwvd3A6VGV
4dDI=PHdwOlBhcmFtPi9xdWlja2Jsb3gueGFtbDwvdA6UGFyYW0=PC93cDpUb2FzdD48L3dwOk5vdGlmaWNhdGlvbj4=&headers=Q
29udGVudC1UeXBlLHRleHQveG1sLENvbnRlbnQtTGVuZ3RoLDIxOCxYLU5vdGlaWNhdGlvbkNsYXNzLDIsWC1XaW5kb3dzUGhvbmUtVGFyZ
2V0LHRvYXN0

Final message (for Blackberry pushes you should add bbps= before message):
event[message]=bbps=PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnPz48d3A6Tm90aWZpY2F0aW9uIHhtbG5zOndwPSdXUE5vdGlm
aWNhdGlvbic=PHdwOlRvYXN0Pjx3cDpUZX0MT5JbmNvbWluZyBNZXNzYWdlPC93cDpUZXh0MT48d3A6VGVdDI=cGluZzwvd3A6VGV
4dDI=PHdwOlBhcmFtPi9xdWlja2Jsb3gueGFtbDwvd3A6UGFyYW0=PC93cDpUb2FzdD48L3dwO5vdGlmaWNhdGlvbj4=&headers=Q
29udGVudC1UeXBlLHRleHQveGsLENvbnRlbnQtTGVuZ3RoLDIxOCxYLU5vdGlmaWNhdGlvbkNsYXNzLDIsWC1XaW5kb3dzUGhvbmUtVGFyZ
2V0LHRvYXN0

Universal Push Notifications

Universal push notifications will be delivered to all possible devices for specified users. To send Universal push notifications just omit event[push_type] parameter.

Send simple text

If you would like to send just text push message (without any parameters):

Example:
Plain message:
I love M&M's! Especially red one!

Base64-encoded:
SSBsb3ZlIE0mTSdzISBFc3BlY2lhbGx5IHJlZCBvbmUh

Final message:
event[message]=SSBsb3ZlIE0mTSdzISBFc3BlY2lhbGx5IHJlZCBvbmUh


Use custom parameters

With custom parameters you can achieve behaviour similar to platform based push notifications.

Note: custom parameters only available for iOS and Android platforms.

There are some constant parameters, which will be translated to particular platform parameters:

  1. message - push text. Will be translated to aps.alert.body for iOS and to data.message for Android
  2. ios_badge - will be translated to aps.badge for iOS. Ignored for Android
  3. ios_sound - will be translated to aps.sound for iOS. Ignored for Android
  4. ios_content-available - will be translated to aps.content-available for iOS. Ignored for Android

You can use any other custom parameters - they will be added as well according to specific platform push format.

Example:
JSON message:
{"message": "Message received from Bob", "ios_badge": 5, "ios_sound": 0, "name": "Bob"}

Base64-encoded:
c29tZXZhbHVlMQc29tZXZhbHVlMQc29tZXZhbHVlMQc29tZXZhbHVlMQc29tZXZhbHVlMQ

Final message:
event[message]=c29tZXZhbHVlMQc29tZXZhbHVlMQc29tZXZhbHVlMQc29tZXZhbHVlMQc29tZXZhbHVlMQ