Sending a Direct Push Notification

If you are an application administrator (developer), you can send push messages on the developer portal or with REST API.

Sending on the developer portal

You can send push messages using the developer portal's UI.

See Sending a Direct Push Notification to learn how the application developer can push messages.

Sending via the REST API

You need to have the app administrator token to send push messages to an application scope topic via REST API. See here to learn how to get the app administrator token.

Here is the sample curl execution.

curl -v -X POST \
  -H "Authorization: Bearer {APP_ADMIN_TOKEN}" \
  -H "Content-Type: application/vnd.kii.SendPushMessageRequest+json" \
  -H "Accept: application/vnd.kii.SendPushMessageResponse+json" \
  "https://api-jp.kii.com/api/apps/{APP_ID}/users/{USER_ID}/push/messages" \
  -d '{
    "data": {
      "message": "Hi all!",
      "content-url" : "https://nice.content.example.com/100",
      "Urgent": false
    },
    "sendToDevelopment": true,
    "sendToProduction": true,
    "gcm": {
      "enabled": true
    },
    "apns": {
      "enabled": true,
      "alert": {
        "body": "Hello"
      }
    },
    "mqtt": {
      "enabled": true
    }
  }'

When sending a push message, specify if you want to send the message to the development and production environments with the sendToDevelopment and sendToProduction fields, respectively. Also, set the enabled fields of the gcm, apns, and mqtt fields to control to which push environments you want to send the message.

Fields specific to each push notification network

You can set parameters specific to each push notification network such as FCM and APNs.

Specify parameters specific to each push notification network under the network name parameter such as gcm and apns in the above curl command. See REST API Overview for parameters available for each push notification network.

The following sample code sets the content-available parameter in order to send a silent notification through APNs.

-d '{
  ......
  "apns": {
    "enabled": true,
    "contentAvailable": true
  },
  ......
}'

The following sample code sets the mutable-content parameter to send a rich notification through APNs. This sample code additionally sets the title, subtitle, body, and category.

-d '{
  ......
  "apns": {
    "enabled": true,
    "alert": {
      "title": "New message",
      "subtitle": "Message from Alice",
      "body": "It's been a while..."
    },
    "mutableContent": true,
    "category": "MESSAGE_CATEGORY"
  },
  ......
}'