Request Headers (Applies to all methods)
POST
/api/apps/{appID}/users/{userID}/push/messages
Send a push message to the current user. A 400 status error with code INVALID_INPUT_DATA will be returned in the following scenarios:
- "gcm" or "apns" fields are not provided in the request.
- "gcm.enabled" or "apns.enabled" fields are not provided in the request.
- "gcm.dryRun" and "apns.enabled" are both set to true.
- "data" contains nested JSONs or arrays.
- "gcm.data" contains values different from String.
- "apns.enabled" is true and "apns.data" contains nested JSONs or arrays.
- "gcm.enabled" is set to true and "data" or "gcm.data" contains a key
that starts with the prefix
"google." or is one of these values:
- from
- registration_ids
- collapse_key
- data
- delay_while_idle
- time_to_live
- restricted_package_name
- dry_run
- "fcm.enabled" is set to true and "data" or "fcm.data" contains a key
that starts with the prefixes
"google." or "gcm." or is one of these values:
- from
- message_type
- collapse_key
- priority
- ttl
- restricted_package_name
- notification
- fcm_options
- direct_boot_ok
- "gcm.enabled" is true and the payload for Android-GCM exceeds 4096 bytes.
- "apns.enabled" is true and the payload for iOS-APNS exceeds 2048 bytes.
If both GCM and FCM specific fields are enabled, the FCM push notification will be prioritized.
FCM-specific fields:
Field | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the FCM installations of the subscribed users. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data | JSON Object with only one-level of nesting, and only strings in values. | Dictionary with the data that will be sent only to Android-FCM devices. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
notification |
JSON Object with the following format:
|
Notification template. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
android |
JSON Object with the following format:
|
Android specific options for messages. |
GCM-specific fields:
Field | Type | Description |
---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the GCM installations of the subscribed users. |
data | JSON Object with only one-level of nesting, and only strings in values. | Dictionary with the data that will be sent only to Android-GCM devices. |
notification | Notification payload. | We supports title, body, icon, sound, tag, color and clickAction fields in notification. Other fields are not supported yet. |
collapseKey | String. Not required. | If provided, it will be used as the GCM notification collapse_key |
delayWhileIdle | Boolean. Not required. | If provided, it will be used as the GCM notification delay_while_idle |
timeToLive | Integer. Not required. | If provided, it will be used as the GCM notification time_to_live |
restrictedPackageName | String. Not required. | If provided, it will be used as the GCM restricted_package_name |
dryRun | Boolean. Not required. If true, the only system that can be enabled is “GCM” - no other system will be accepted. | If provided, it will be used as the GCM dry_run |
iOS-APNS specific fields:
Field | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the APNS installations of the subscribed users. | ||||||||||||||||
data | JSON Object with only one-level of nesting, and only strings, integers, booleans or doubles in the values. | Dictionary with the data that will be sent only to iOS-APNS devices. | ||||||||||||||||
alert |
JSON Object with the format:
|
All the information related to the alert that will be shown when the notification is received with the app turned off. See details in APNS documentation. | ||||||||||||||||
sound | String. Not required. | If provided, it will be used as the “sound” to be sent with the notification. See details in APNS documentation. | ||||||||||||||||
badge | Number. Not required. | If provided, it will be used as the “badge” to be sent with the notification. See details in APNS documentation. | ||||||||||||||||
contentAvailable | Boolean. Not required. | If provided and has "true" value, it will be set "1" to the field "content-available" in the notification, otherwise that field will not be sent. See details in APNS documentation. | ||||||||||||||||
category | String. Not required. | If provided, it will be used as the “category” to be sent with the notification. See details in APNS documentation. | ||||||||||||||||
mutableContent | Boolean. Not required. | If provided and has "true" value, the value "1" will be set to the field "mutable-content" in the notification; otherwise the field will not be sent. See details in APNS documentation. |
JPUSH specific fields:
Field | Type | Description |
---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the JPUSH installations of the subscribed users. |
data | JSON Object with only one-level of nesting, and only strings in values. | Dictionary with the data that will be sent only to JPUSH devices. |
MQTT specific fields:
Field | Type | Description |
---|---|---|
enabled | Boolean. Required. | If true, it will send the message to the MQTT installations of the subscribed users. |
data | JSON Object with only one-level of nesting, and only strings in values. | Dictionary with the data that will be sent only to MQTT devices. |
dryRun | Boolean. Not required, | Used for testing. If provided with "true" value, the message will not be sent to the device. Default is "false". |
retain | Boolean. Not required. | Retain message. (currently always false) |
qos | Integer. Not required. | Quality of service for the message (default will be 0 - fire and forget) |
Can be performed only by administrator
Content-Type application/vnd.kii.SendPushMessageRequest+json
All the data to a send message. The format of the request and responses is the same as in send a push message to a topic and applies the same validation rules, but in this case the fields sendAppID, sendObjectScope and sendTopicID do not apply, since there is not a topic involved.
{
"data": "[JSONObject]",
"sendToDevelopment": "[boolean]",
"sendToProduction": "[boolean]",
"pushMessageType": "[string]",
"sendSender": "[boolean]",
"sendWhen": "[boolean]",
"sendOrigin": "[boolean]",
"sendAppID": "[boolean]",
"sendObjectScope": "[boolean]",
"sendTopicID": "[boolean]",
"sendSourceURI": "[boolean]",
"sendSenderURI": "[boolean]",
"fcm": "[FCMType]",
"gcm": "[GCMType]",
"apns": "[APNSType]",
"jpush": "[JPUSHType]",
"mqtt": "[MQTTType]"
}
Content-Type application/vnd.kii.SendPushMessageResponse+json
Name | Type | Description |
---|---|---|
pushMessageID | string | The ID of the sent message |
Content-Type application/vnd.kii.UserNotFoundException+json
Name | Type | Description |
---|---|---|
errorCode | string | Error code "USER_NOT_FOUND". |
message | string | The error message. |
field | string | The field used for searching the user. This can be the userID or address field. |
value | string | The field value used for searching the user. |
appID | string | The ID of the application. |
Content-Type application/vnd.kii.UnauthorizedAccessException+json
Name | Type | Description |
---|---|---|
errorCode | string | Error code "UNAUTHORIZED". |
message | string | The error message. |
authenticatedAppID | string | The authenticated appID. |
authenticatedPrincipalID | string | The authenticated principal ID (userID or thingID). |