Recipe
1. Use an `event` parameter to set data associated with the event
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
}
}' \
https://api.quickblox.com/events.json
2. Set a notification type
Use a notication_type
parameter to set the type of notification. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
}
}' \
https://api.quickblox.com/events.json
3. Set a push notification environment
Use an environment
parameter to set the notification environment. Here, the production environment is set which means the pushes will work for a production environment only. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
}
}' \
https://api.quickblox.com/events.json
4. Use a `user` parameter to set the ID of push notification recipient.
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"user":{
},
}
}' \
https://api.quickblox.com/events.json
5. Set the ID of push notification recipient
You can specify as many IDs as you need via comma. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"user":{
"ids":"96831397"
},
}
}' \
https://api.quickblox.com/events.json
6. Set a push message
A push message text should be Base64-encoded. Here, the iOS push message is set. For iOS push, you should add a payload before a message. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"user":{
"ids":"96831397"
},
"message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
}
}' \
https://api.quickblox.com/events.json
7. Set a push notification platform
Use a push_type
parameter to set the push notification platform. Here, the push_type
is set to apns
. This means that the push will be delivered to iOS devices. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"user":{
"ids":"96831397"
},
"message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
"push_type":"apns"
}
}' \
https://api.quickblox.com/events.json
8. As a result, the API returns a newly created event.
{
"event" : {
"id" : 30961913 ,
"event_type" : "one_shot" ,
"message" : "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19" ,
"date" : null ,
"period" : null ,
"name" : null ,
"occured_count" : 0 ,
"created_at" : "2019-11-09T19:40:25Z" ,
"updated_at" : "2019-11-09T19:40:25Z" ,
"end_date" : null ,
"active" : true ,
"application_id" : 76730 ,
"user_id" : 91142495 ,
"kind" : "API" ,
"environment" : "production" ,
"tag_query" : null ,
"notification_channel" : {
"name" : "apns"
}
}
}
Create event with period date
1. Use an `event` parameter to set data associated with the event
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
}
}' \
https://api.quickblox.com/events.json
2. Set a notification type
Use a notication_type
parameter to set the type of notification. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
}
}' \
https://api.quickblox.com/events.json
3. Set a push notification environment
Use an environment
parameter to set the notification environment. Here, the production environment is set which means the pushes will work for a production environment only. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
}
}' \
https://api.quickblox.com/events.json
4. Set an event type
Use an event_type
method to set the event type. Here, the period_date
event type is set. This event occurs within a given period from the initial date. Valid only if the period
is specified. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"event_type":"period_date",
}
}' \
https://api.quickblox.com/events.json
5. Set a date of the event
Use a date
parameter to set the date for the event to be sent on. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"event_type":"period_date",
"date":"1567556125",
}
}' \
https://api.quickblox.com/events.json
6. Set a period of the event
Use a period
parameter to set the period of the event. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"event_type":"period_date",
"date":"1567556125",
"period":"86400",
}
}' \
https://api.quickblox.com/events.json
7. Set an end date of the event
Use an end_date
parameter to set the date for the event to end. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"event_type":"period_date",
"date":"1567556125",
"period":"86400",
"end_date":"1568556125",
}
}' \
https://api.quickblox.com/events.json
8. Set a push message
A push message text should be Base64-encoded. Here, the iOS push message is set. For iOS push, you should add a payload before a message. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"event_type":"period_date",
"date":"1567556125",
"period":"86400",
"end_date":"1568556125",
"message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
}
}' \
https://api.quickblox.com/events.json
9. Set a push notification platform
Use a push_type
parameter to set the push notification platform. Here, the push_type
is set to apns
. This means that the push will be delivered to iOS devices. curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 1c3c3584d472a4416eca65df9474ed2cee012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"event_type":"period_date",
"date":"1567556125",
"period":"86400",
"end_date":"1568556125",
"message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
"push_type":"apns"
}
}' \
https://api.quickblox.com/events.json
10. As a result, the API returns a newly created event.
{
"event" : {
"id" : 30534811 ,
"event_type" : "period_date" ,
"message" : "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19" ,
"date" : 1567556125 ,
"period" : 86400 ,
"name" : null ,
"occured_count" : 1 ,
"created_at" : "2019-09-02T20:29:55Z" ,
"updated_at" : "2019-09-02T20:29:55Z" ,
"end_date" : 1568556125 ,
"active" : true ,
"application_id" : 76730 ,
"user_id" : 91141808 ,
"kind" : "API" ,
"environment" : "production" ,
"tag_query" : null ,
"notification_channel" : {
"name" : "apns"
}
}
}
Create event for users with tags
Only one of (Optional) parameters is required.
Body Parameters
Type of notification. Possible values are: push
and email.
Used only if notification_type=push
, otherwise ignored. If not set, the notification will be delivered to all possible devices for specified users. Possible values are: apns
, apns_voip
, gcm
.
An environment of the notification. Possible values are: development
and production
.
Event type. Possible values are:
one_shot
- a one-time event caused by an external object (valid only if the date
is not specified).
fixed_date
- a one-time event that occurs at a specified date (valid only if the date
is specified).
period_date
- is a reusable event that occurs within a given period from the initial date (valid only if the period
is specified).
Default:
one_shot
- if date
is not specified.
period_date
- if period
is specified.
fixed_date
- if date
is specified.
Encoded message payload. Possible values are: Base64 encoded plain text or
push notification payload (Push notifications formats ).
(Optional) Notification’s recipients should contain a string of users’ IDs divided by commas.
(Optional) Notification recipients should contain a string of tags divided by commas.
Recipients must have at least one tag specified in the list.
(Optional) Notification recipients should contain a string of tags divided by commas.
Recipients must have ALL tags specified in the list.
(Optional) Notification recipients should contain a string of tags divided by commas.
Recipients must not have tags specified in the list.
Show external_user object
(Optional) Notification recipients should contain a string of external users’ IDs divided by commas.
The date of the event to send on. If the event_type=fixed_date
, the date
can not be in the past.
The date when the event is completed. Must be not less than the date
.
The period of the event in seconds.
The name of the event. Service information. Only for your own usage.
A user or application session token. See
Authentication page to learn more about session tokens. Must be used either QB-Token or Authorization.
Responses
curl -X POST \
-H "Content-Type: application/json" \
-H "QB-Token: 519c40c31072fe5dcbe0c24651c7489fab012bba" \
-d '{
"event":{
"notification_type":"push",
"environment":"production",
"user":{
"ids":"96831397"
},
"message":"payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19",
"push_type":"apns"
}
}' \
https://api.quickblox.com/events.json
{
"event" : {
"id" : 30961913 ,
"event_type" : "one_shot" ,
"message" : "payload=eyJhcHMiOnsiYWxlcnQiOiJIZWxsbywgV29ybGQhIiwiYmFkZ2UiOjc3Nywic291bmQiOiJkZWZhdWx0In19" ,
"date" : null ,
"period" : null ,
"name" : null ,
"occured_count" : 0 ,
"created_at" : "2019-11-09T19:40:25Z" ,
"updated_at" : "2019-11-09T19:40:25Z" ,
"end_date" : null ,
"active" : true ,
"application_id" : 76730 ,
"user_id" : 91142495 ,
"kind" : "API" ,
"environment" : "production" ,
"tag_query" : null ,
"notification_channel" : {
"name" : "apns"
}
}
}