For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.
Send Message (POST)
Sends message with different options.
Roles
Users in the following roles are authorized to perform this operation:
- mfpadmin
- mfpdeployer
- mfpoperator
Method
POST
Path
/management-apis/2.0/runtimes/runtime-name/notifications/applications/application-name/messages
Example
https://www.example.com/mfpadmin/management-apis/2.0/runtimes/myruntime/notifications/applications/myapplication/messages?locale=de_DE
Path Parameters
- runtime-name
- The name of the runtime. This is the context root of the runtime web application, without the leading slash.
- application-name
- The name of the application.
Query Parameters
Query parameters are optional.
- locale
- The locale used for error messages.
Consumes
application/json, application/xml, text/xml
Produces
application/json, application/xml, text/xml
Payload
JSON Example
{ "message" : { "alert" : "New update available", }, "settings" : { "apns" : { "delayWhileIdle" : true, "payload" : "", "sound" : "song.mp3", "timeToLive" : 100, }, "gcm" : { "badge" : 1, "iosActionKey" : "Ok", "payload" : "", "sound" : "song.mp3", "type" : "SILENT", }, "wns" : { "badge" : , "cachePolicy" : false, "expirationTime" : 20, "raw" : , "tile" : , "toast" : , }, }, "target" : { "deviceIds" : "[TestDeviceId,..]", "platforms" : "[A,G,W]", "tagNames" : "[TestTag...]", "userIds" : [ "MyUserId", ... ], }, }
XML Example
<?xml version="1.0" encoding="UTF-8"?> <send-message> <message alert="New update available"/> <settings> <apns delayWhileIdle="true" payload="" sound="song.mp3" timeToLive="100"/> <gcm badge="1" iosActionKey="Ok" payload="" sound="song.mp3" type="SILENT"/> <wns badge="" cachePolicy="false" expirationTime="20" raw="" tile="" toast=""/> </settings> <target deviceIds="[TestDeviceId,..]" platforms="[A,G,W]" tagNames="[TestTag...]"> <userIds> <userId>MyUserId</userId> ... </userIds> </target> </send-message>
Payload Properties
The payload has the following properties:
- message
- The notification message to be sent
- settings
- The settings for GCM, APNS and WNS
- target
- The targets for sendig the notification
The alert messages has the following properties:
- alert
- A string to be displayed in the alert.
The message 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 an Windows device
The apns settings has the following properties:
- badge
- An integer value to be displayed in a badge on the application icon.
- 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 settings has the following properties:
- delayWhileIdle
- A Boolean value to indicate 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.
- 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.
- timeToLive
- The duration (in seconds) that the message is kept on GCM storage if the device is offline. The default value is 4 weeks, and must be set as a JSON number.
The wns settings has the following properties:
- badge
- Optional. A numeric or string value that indicates a prdefined glyph to be displayed.
- cachePolicy
- Optional. A boolean value that indicates if the notification should be cached or not.
- expirationTime
- Optional. Expriry time of the notification.
- raw
- Optional. A JSON block that is transferred to the application only if the application is already open.
- tile
- Optional. Updates to tile to communicate new information to the user
- toast
- Optional. Updates to the toast to communicate new information to the user
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
- Optional. Visual settings for the notification
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
- Optional. 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 toast has the following properties:
- audio
- Optional. Audio settings for the notification
- 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
- Optional. Visual settings for the notification
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 settings has the following properties:
- deviceIds
- A JSON array of the device identifiers. Devices with these ids receive notification.
- platforms
- A JSON array of platforms. The devices that run on these platforms receive notification. Supported values are A (Apple/iOS), G (Google/Android) and W (Microsoft/Windows).
- tagNames
- A JSON array of tags. The devices that are subscribed to these tags receive notification.
- userIds
- An array of users represented by their userIds to send the notification. This is a unicast notification.
Errors
400The request was not understood by the push server.403
The user is not authorized to call this service.404
The corresponding runtime or application is not found or not running.500
An internal error occurred.
Parent topic: REST API for the MobileFirst Server administration service