Push notifications API
Push notifications are a communication channel built into every mobile device sold today. Push notifications allow apps to reach out to users with short messages that users may respond to. Users don’t have to be in the app or using their devices to receive them.
ConnectyCube provides an API to subscribe users for push notifications and to initiate push events.
To send a notification on user’s device, the following actions should be initially completed:
On receiver’s side:
On sender’s side:
Create subscription
Endpoint
Parameters
Parameter | Required | Description |
---|---|---|
notification_channel | yes | Declare which notification channels could be used to notify user about events: |
push_token[environment] | yes | Determines application environments. It allows conveniently separate development and production environments. Allowed values: |
push_token[bundle_identifier] | no | A unique identifier for client’s application. In iOS, this is the Bundle Identifier. In Android - package id |
push_token [client_identification_sequence] | yes | Identifies client device in 3-rd party service like APNS, GCM/FCM. Initially retrieved from 3-rd service and should be send to ConnectyCube to let it send push notifications to the client |
device[platform] | yes | Platform of device, which is the source of application running. Allowed values: |
device[udid] | yes | UDID (Unique Device identifier) of device, which is the source of application running. This must be any sequence which uniquely identifies a particular device. This is needed to support schema: 1 User - Multiple devices |
Request example
Response
Retrieve subscriptions
Retrieve subscriptions for current user.
Request example
Response
Remove subscription
Remove a subscription by its identifier.
Endpoint
Request example
Response
Create event
Create event to initiate a push notification delivery.
Endpoint
Parameter
Parameter | Required | Type | Description |
---|---|---|---|
event[notification_type] | yes | enum | Type of notification. Allowed values: |
event[push_type] | yes | enum | Used only if notification_type == push, ignored in other cases. |
event[environment] | yes | enum | An environment of the notification. Allowed values: |
event[event_type] | no | enum | Allowed values: |
event[message] | yes | Push notification payload | |
event[user][ids] | optional* | string | Users who will receive push notifications. Several IDs comma separated can be specified |
event[external_user][ids] | optional* | string | Send push notifications to users specifying their external IDs. Several external IDs comma separated can be specified |
event[user][tags][any] | optional* | string | Send push notifications to users specifying their tag(s). Recipients must have at least one tag specified in the list of tags |
event[user][tags][all] | optional* | string | Send push notifications to users specifying their tag(s). Recipients must have all tags specified in list of tags |
event[user][tags][exclude] | optional* | string | Send push notifications to users who do not have the specified tags |
** Only one of these parameters is required.*
Request example
Response
Payload formation rules
Universal Push Notifications
Universal push notifications will be delivered to all platforms. To send Universal push notification do not set event[push_type]
parameter in the ‘Create event’ request.
There are some standard parameters, which will be translated to particular platform parameters:
- message - push text. Will be translated to
aps.alert.body
for iOS and todata.message
for Android - ios_badge - will be translated to
aps.badge
for iOS. Ignored for Android - ios_sound - will be translated to
aps.sound
for iOS. Ignored for Android - ios_content_available=1 - will be translated to
aps.content-available
for iOS. Ignored for Android - ios_mutable_content=1 - will be translated to
aps.mutable-content
for iOS. Ignored for Android - ios_category - will be translated to
aps.category
for iOS. Ignored for Android - ios_voip=1 - will initiate VoIP push notification for iOS if user has VoIP push subscription. Otherwise - iOS user will receive standard iOS push. For Android - it will be a standard push.
- ios_push_type - will be translated to
apns-push-type
header for iOS. Allowed values (alert
,background
), defaultalert
. Ignored for Android - ios_thread_id - will be translated to
aps.thread-id
for iOS. Ignored for Android - expiration - A UNIX epoch date expressed in seconds (UTC). This value identifies the date when the notification is no longer valid and can be discarded. In short, the value should equal ‘current timestamp’ + ‘ttl offset, in seconds’. Will be translated to
apns-expiration
for iOS andtime-to-live
orttl
for Android FCM - android_fcm_notification - will be translated to ‘notification.*’ param on Android. Ignored for iOS. Available fields
- ios_loc_data - object with notification localization settings for iOS. Ignored for Android
Object example:
title_loc_key
- will be translated to aps.alert.title-loc-key
title_loc_args
- will be translated to aps.alert.title-loc-args
body_loc_key
- will be translated to aps.alert.loc-key
body_loc_args
- will be translated to aps.alert.loc-args
None of these parameters are required
Other custom parameters can be used as well according to specific platform push format.
Example:
- Initial JSON message:
- Base64-encoded:
- Final message: