Push Message (POST)

Send message with different options.

Description

Sends a push notifications to the specified targets and returns HTTP return code 202 when the request to send the message is accepted.

Method

POST

Path

/apps/applicationId/messages

Example

https://example.com:443/imfpush/v1/apps/myapp/messages

Path Parameters

applicationId
The name or identifier of the application

Header Parameters

Some header parameters are optional.

Accept-Language
(Optional) The preferred language to use for error messages. Default:en-US
Authorization
The token with the scope "messages.write" and "push.application.<applicationId>" obtained using the confidential client in the format Bearer token.. This parameter has to be mandatorily set.

Consumes

application/json

Produces

application/json

Payload

The payload in JSON format has values for message, target, and settings.

JSON Example


{
  "message": {
    "alert": "Test message"
  },
  "notificationType": 1,
  "settings": {
    "apns": {
      "attachmentUrl": "http://test.com/test.png",
      "subtitle": "Sub Title",
      "title": "Title",
      "badge": 1,
      "category": 1,
      "iosActionKey": "Ok",
      "payload": {
        "custom": "data"
      },
      "sound": "song.mp3",
      "type": "SILENT"
    },
    "gcm": {
      "bridge": false,
      "category": "email",
      "collapseKey": "testkey",
      "delayWhileIdle": false,
      "payload": {
        "custom": "data"
      },
      "priority": "low",
      "redact": "Test Redact Message",
      "sound": "song.mp3",
      "sync": false,
      "timeToLive": 10,
      "visibility": "public"
    },
    "wns": {
      "badge": {
        "value": "10"
      },
      "cachePolicy": false,
      "expirationTime": 20,
      "raw": {
        "payload": {
          "custom": "data"
        }
      },
      "tile": {
        "visual": {
          "binding": [{
            "template": "TileSquareText04",
            "text": [{
              "content": "Text1"
            }]
          }, {
            "template": "TileWideText04",
            "text": [{
              "content": "Text1"
            }]
          }]
        }
      },
      "toast": {
        "launch": {
          "custom": "data"
        },
        "visual": {
          "binding": {
            "template": "ToastText04",
            "text": [{
              "content": "Text1"
            }, {
              "content": "Text2"
            }, {
              "content": "Text3"
            }]
          }
        }
      }
    },
    "target": {
      "deviceIds": ["MyDeviceId1", ...],
      "platforms": ["A,G", ...],
      "tagNames": ["Gold", ...],
      "userIds": ["MyUserId", ...],
    }
  }
} 

Payload Properties

The payload has the following properties:
message
The alert message to be sent
notificationType
Integer value to indicate the channel (Push/SMS) used to send message. Allowed values are 1 (only Push), 2 (only SMS) and 3 (Push and SMS)
settings
The settings are the different attributes of the notification.
target
Set of targets can be user Ids, devices, platforms, or tags. Only one of the targets can be set.

The message has the following properties:

alert
A string to be displayed in the alert.

The settings has the following properties:

apns
Attributes for sending message to an iOS device.
gcm
Attributes for sending message to an Android device.
wns
Attributes for sending message to a windows device.

The apns has the following properties:

attachmentUrl
The link to the iOS notifications media (video, audio, GIF, images - Supported only on iOS 10 and above).
subtitle
The subtitle of the Rich Notifications.(Supported only on iOS 10 and above).
title
The title of Rich Push notifications (Supported only on iOS 10 and above).
badge
An integer value to be displayed in a badge on the application icon.
category
Name of the category for iOS8 interactive push notifications.
iosActionKey
The label of the dialog box button that allows the user to open the app upon receiving the notification.
payload
A JSON block that is transferred to the application if the application is opened by the user when the notification is received, or if the application is already open.
sound
The name of a file to play when the notification arrives.
type
Specify the type of APNS notification. It should be either DEFAULT, MIXED or SILENT

The gcm has the following properties:

bridge
A Boolean value that indicates whether the notification should be bridged or not to other devices connected to this handheld device. Only applies to Android 5.0 or higher.
category
A string value that indicates the category to which this notification belongs. Allowed values are 'call', 'alarm', 'email', 'err', 'event', 'msg', 'progress', 'promo', 'recommendation', 'service', 'social', 'status', and 'transport'. Only applies to Android 5.0 or higher.
collapseKey
A string value that indicates that the message can be replaced. When multiple messages are queued up in GCM Servers with the same key, only the last one is delivered.
delayWhileIdle
A Boolean value that indicates that the message must not be sent if the device is idle. The server waits for the device to become active before the message is sent. Default value is false
payload
A JSON block that is transferred to the application if the application is opened by the user when the notification is received, or if the application is already open.
priority
A string value that indicates the priority of this notification. Allowed values are 'max', 'high', 'default', 'low' and 'min'. High/Max priority notifications along with 'sound' field may be used for Heads up notification in Android 5.0 or higher.
redact
A string to be displayed in the alert as a redacted version of the original content when the visibility level is 'private'. Only applies to Android 5.0 or higher.
sound
The name of a sound file on the device to play when the notification arrives to the device.
sync
A Boolean value that indicates whether the notification should be sync'd between devices of the same user, that is, if a notification is handled on a device it gets dismissed on the other devices of the same user
timeToLive
The duration (in seconds) that the message is kept on GCM storage if the device is offline. Default value is 4 weeks, and must be set as a JSON number.
visibility
A string value that indicates the visibility level of notification content on the secured lock screen in Android L devices. Allowed values are 'public, 'private' and 'secret'. Only applies to Android 5.0 or higher.

The wns has the following properties:

badge
cachePolicy
A boolean value that indicates if the notification should be cached or not.
expirationTime
Optional. Expriry time of the notification.
raw
tile
toast

The badge has the following properties:

value
Optional. A numeric or string value that indicates a prdefined glyph to be displayed.
version
Optional. Version of the payload.

The raw has the following properties:

payload
Optional. A JSON block that is transferred to the application only if the application is already open.

The tile has the following properties:

tag
Optional. A string value that is set as label for the notification. Used in notification cycling.
visual

The visual has the following properties:

addImageQuery
Optional. A boolean value that indicates if the query string need to be appended to image URI.
baseUri
Optional. Base URI to be combined with the relative URIs.
binding
For tile notifications, its a JSON array containing JSON blocks of binding attributes. For toast notification, its a JSON block of binding attributes.
branding
Optional. Indicates whether logo or app's name to be shown. Default is None.
contentId
Optional. A string value that identifies the notification content. Only applies to tile notifications.
lang
Optional. Locale of the payload.
version
Optional. Version of the payload.

The binding has the following properties:

addImageQuery
Optional. A boolean value that indicates if the query string need to be appended to image URI.
baseUri
Optional. Base URI to be combined with the relative URIs.
branding
Optional. Indicates whether logo or app's name to be shown. Default is None.
contentId
Optional. A string value that identifies the notification content. Only applies to tile notifications.
fallback
Optional. Template to be used as a fallback.
image
Optional. A JSON array containing JSON blocks of following image attributes.
lang
Optional. Locale of the payload.
template
Mandatory. Template type of the notification.
text
Optional. A JSON array containing JSON blocks of following text attributes.

The image has the following properties:

addImageQuery
Optional. A boolean value that indicates if the query string need to be appended to image URI.
alt
Optional. Image description.
src
Mandatory. Image URI.

The text has the following properties:

content
Mandatory. A string value that is displayed in the toast.
lang
Optional. Locale of the payload.

The toast has the following properties:

audio
duration
Optional. Notification will be displayed for the specified duration. Should be 'short' or 'long'.
launch
Optional. A string value that is passed to the application when it is launched by tapping or clicking the toast notification.
visual

The audio has the following properties:

loop
Optional. A boolean value to indicate if the sound should be repeated or not.
silent
Optional. A boolean value to indicate if the sound should be played or not.
src
Optional. A string value that specifies the notification sound type or path to local audio file.

The target has the following properties:

deviceIds
An array of the devices represented by the device identifiers. Devices with these ids receive the notification. This is a unicast notification
platforms
An array of device platforms. Devices running on these platforms receive the notification. Supported values are A (Apple/iOS), G (Google/Android) and W (Microsoft/Windows).
tagNames
An array of tags specified as tagNames. Devices that are subscribed to these tags receive the notification. Use this type of target for tag based notifications
userIds
An array of users represented by their userIds to send the notification. This is a unicast notification.

Response

The details of the message that is retrieved.

JSON Example

{
  "message" : {
    "message" : {
      "alert" : "TestMessage",
    },
  },
  "messageId" : "1234",
}

Response Properties

The response has the following properties:

message
The array of messages to be sent
messageId
The unique identifier of the message.

The messages has the following properties:

message
The message to be sent

The message has the following properties:

alert
The message text.

Errors

400
Invalid JSON.
403
The user is not authorized to call this service.
404
The corresponding runtime is not found or not running.
500
An internal error occurred.