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",
      "badge" : 1,
      "iosActionKey" : "Ok",
      "launchImage" : "test.png",
      "locArgs" : [ "["Shelly"]", ... ],
      "locKey" : "REQ_FORMAT",
      "payload" : {"custom":"data"},
      "sound" : "song.mp3",
      "subtitle" : "Sub Title",
      "title" : "Title",
      "titleLocArgs" : [ "["Shelly"]", ... ],
      "titleLocKey" : "REQ_FORMAT",
      "type" : "SILENT",
      "category" : "confirmOrder"
    },
    "gcm": {
      "bridge" : false,
      "category" : "email",
      "collapseKey" : "testkey",
      "delayWhileIdle" : false,
      "lights" : {"ledArgb":"green","ledOnMs": 100,"ledOffMs" : 100},
      "payload" : {"custom":"data"},
      "priority" : "low",
      "redact" : "Test Redact Message",
      "sound" : "song.mp3",
      "style" : {"notification_type":"inbox_notification","lines":["first line","second line","third line"],"title" : "This is the title."},
      "sync" : false,
      "timeToLive" : 10,
      "visibility" : "public",
      "interactiveCategory" : "confirmOrder"
    },
    "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
(Deprecated. Use interactiveCategory for interactive push notification)
interactiveCategory
Specify the identifier of the interactive notification action category
iosActionKey
The label of the dialog box button that allows the user to open the app upon receiving the notification.
launchImage
The filename of an image file in the app bundle, with or without the filename extension. The image is used as the launch image when users tap the action button or move the action slider.
locArgs
Variable string values to appear in place of the format specifiers in locKey.
locKey
A key to an alert-message string in a Localizabl.strings file for the current localization (which is set by the user’s language preference). The key string can be formatted with %@ and %n$@ specifiers to take the variables specified in the locArgs array.
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).
titleLocArgs
Variable string values to appear in place of the format specifiers in title-loc-key.
titleLocKey
The key to a title string in the Localizable.strings file for the current localization. The key string can be formatted with %@ and %n$@ specifiers to take the variables specified in the titleLocArgs array.
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
lights
Optional. A JSON object with different color options for notification LED.
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.
style
Optional. A JSON object with different types of notification styles.
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.
interactiveCategory
Specify the identifier of the interactive notification action category

The lights has the following properties:

ledArgb
A color name to display in LED
ledOffMs
Time to keep LED off in milliseconds.
ledOnMs
Time to keep LED on in milliseconds.

The style has the following properties:

lines
Different lines to form inbox style notification
notification_type
Type of style of notification to send. Different values are 'PICTURE_NOTIFICATION','INBOX_NOTIFICATION','BIGTEXT_NOTIFICATION'
text
Big text to be sent as a notification.
title
Title for notification.
url
The link to the notifications media ( GIF, images)

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.

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.