Reference of the Notification object used to specify content when sending notifications via the REST API
This object represents what the user will see. It is split into 3 main fields: alert
, inApp
and push
. alert
controls what the user will see in the notification center, and push
controls various payload and push options.
The simplest form of notification you can create contains only a text alert:
{"alert":{"text": "Hello, WonderPush!"}}
Localization
Field | Type | Description |
---|---|---|
locale | string | The locale in the form |
Notification
The alert
top-level field controls the user-visible notification.
Field | Type | Description |
---|---|---|
alert.text | string. Mandatory | The message to display in the notification center. |
alert.title | string. Optional | The title of the notification to display in the notification center. |
alert.targetUrl | a URL. Optional | The content that should be displayed when the user clicks the notification.
|
alert.tag | string, | If a notification using the same tag is currently displayed, it will be updated, otherwise, a new notification is shown. |
alert.actions | array of actions . Optional | An optional list of background actions to perform when the user clicks the notification. |
alert.ios | object. See below . Optional | iOS specific options |
alert.android | object. See below . Optional | Android specific options |
alert.web | object. See below . Optional | Web specific options |
alert.ios
alert.ios
The following table presents the iOS specific options that can be user in the alert.ios
field:
Field | Type | Description |
---|---|---|
alert.ios.sound | string | The name of a sound file in the app bundle or in the |
alert.ios.badge | integer | The number to display as the badge of the app icon. |
alert.ios.titleLocKey | string | The key to a title string in the |
alert.ios.titleLocArgs | array of string | Variable string values to appear in place of the format specifiers in |
alert.ios.subtitle | string | A second line of title. |
alert.ios.subtitleLocKey | The key to a subtitle string in the | |
alert.ios.subtitleLocArgs | Variable string values to appear in place of the format specifiers in | |
alert.ios.body | string | The text of the alert message. |
alert.ios.locKey | string | A key to an alert-message string in a |
alert.ios.locArgs | array of string | Variable string values to appear in place of the format specifiers in |
alert.ios.actionLocKey | string | If a string is specified, the system displays an alert that includes the Close and View buttons. The string is used as a key to get a localized string in the current localization to use for the right button’s title instead of “View”. See Localized Formatted Strings for more information. |
alert.ios.launchImage | string | 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. If this property is not specified, the system either uses the previous snapshot,uses the image identified by the |
alert.ios.category | string | Provide this key with a string value that represents the |
alert.ios.attachments | array of objects | A list of media attachments to add to the notification. iOS 10 only shows the first one but you may use the others in you have your own Notification Content Extension. Requires at least SDK v1.2.2.0. |
alert.ios.attachments[].id | string | An optional identifier for use in your own Notification Content Extension if you have one. |
alert.ios.attachments[].url | string | The URL to the media to download and attach to the notification. |
alert.ios.attachments[].type | string | The type of the file that |
alert.ios.attachments[].options | object | Optional list of additional raw options to pass to the notification attachment constructor method. |
alert.ios.contentAvailable | integer | Provide this key with a value of |
alert.ios.mutableContent | integer | Provide this key with a value of |
alert.ios.threadId | string | Provide this key with a string value that represents the app-specific identifier for grouping notifications. If you provide a Notification Content app extension, you can use this value to group your notifications together. |
alert.ios.targetContentId | string | The identifier of the window to bring forward. |
alert.ios.foreground | object | Permits to customize some behavior if the notification is to be displayed while the application is foreground. |
alert.ios.foreground.autoOpen | boolean | Whether to automatically do as if the user clicked the notification if received while in foreground. |
alert.ios.foreground.autoDrop | boolean | Whether to automatically do as if the user swiped the notification if received while in foreground. |
alert.ios.buttons | array of objects | A list of up to 3 buttons to add to the notification. |
alert.ios.buttons[].label | string | The button label |
alert.ios.buttons[].targetUrl | URL | The content to open when clicking on the button, as an alternative to clicking on the notification itself. |
alert.ios.buttons[].actions | array of actions | A list of background options to perform when clicking on the button. |
You can read more about those fields in the Apple documentation about The Remote Notification Payload.
If neither alert.ios.foreground.autoOpen
nor alert.ios.foreground.autoDrop
are set, the SDK presents the notification. On iOS 10, if you properly integrated the SDK v1.2.2.0 or later the OS itself will present the notification. On prior versions of iOS or if the your code does not call [WonderPush setupDelegateForUserNotificationCenter]
on initialization, the SDK will present an alert with the notification title and text.
alert.android
alert.android
The following table presents the Android specific options that can be user in the alert.android
field:
Field | Type | Description |
---|---|---|
alert.android.channel | string | The Android O notification channel to post the notification to. Prior to Android O, the WonderPush SDK can associate user preferences just about the same way. |
alert.android.type | string | One of:
|
alert.android.bigTitle | string or HTML | An alternate title when the notification is expanded. |
alert.android.bigText | string or HTML | An alternate content when the notification is expanded. |
alert.android.summaryText | string or HTML | A last line of text to show under a horizontal ruler. |
alert.android.bigLargeIcon | URL or resource name | An alternate large icon to show then the notification is expanded. |
alert.android.bigPicture | URL | A large picture to display when the notification is expanded. |
alert.android.lines | array of strings or HTML | A list of single line sentences to show when the notification is expanded. |
alert.android.html | boolean | Whether to treat every displayable string in this object as being HTML styled. |
alert.android.title | string or HTML | Set the first line of text in the platform notification template. |
alert.android.text | string or HTML | Set the second line of text in the platform notification template. |
alert.android.subText | string or HTML | This provides some additional information that is displayed in the notification. |
alert.android.info | string or HTML | A small piece of additional information pertaining to this notification. The platform template will draw this on the last line of the notification, at the far right (to the right of a smallIcon if it has been placed there). |
alert.android.ticker | string or HTML | Set the "ticker" text which is sent to accessibility services. |
alert.android.priority | string | One of:
|
alert.android.persons | array of URIs | Add a person that is relevant to this notification. The system will also attempt to resolve |
alert.android.category | string | One of the Notification category constants, like |
alert.android.color | string | One of the Color constants, or an |
alert.android.group | string | Set this notification to be part of a group of notifications sharing the same key. Grouped notifications may display in a cluster or stack on devices which support such rendering. |
alert.android.groupTargetUrl | string or | By default, clicking on the unfolded group notification will use the You can override this using this field. You can also give |
alert.android.sortKey | string | Set a sort key that orders this notification among other notifications from the same package. This can be useful if an external sort was already applied and an app would like to preserve this. Notifications will be sorted lexicographically using this value, although providing different priorities in addition to providing sort key may cause this value to be ignored. |
alert.android.localOnly | boolean | Set whether or not this notification should not bridge to other devices. Some notifications can be bridged to other devices for remote display. This hint can be set to recommend this notification not be bridged. |
alert.android.number | integer | Set the large number at the right-hand side of the notification. This is equivalent to |
alert.android.onlyAlertOnce | boolean | Set this flag if you would only like the sound, vibrate and ticker to be played if the notification is not already showing. |
alert.android.when | timestamp in milliseconds | Add a timestamp pertaining to the notification (usually the time the event occurred). For apps targeting N and above, this time is not shown anymore by default and must be opted into by using |
alert.android.showWhen | boolean | Control whether the timestamp set with For apps targeting N and above, this defaults to false. For earlier apps, the default is true. |
alert.android.usesChronometer | boolean | Show the when field as a stopwatch. Instead of presenting when as a timestamp, the notification will show an automatically updating display of the minutes and seconds since Useful when showing an elapsed time (like an ongoing phone call). The counter can also be set to count down to |
alert.android.chronometerCountDown | boolean | Sets the Chronometer to count down from This is only relevant if |
alert.android.timeoutAfter | duration in milliseconds | Specifies a duration in milliseconds after which this notification should be automatically closed. This is a built-in Android feature. |
alert.android.visibility | string | One of:
|
alert.android.lights | boolean or object | Set the desired color for the indicator LED on the device, as well as the blink duty cycle (specified in milliseconds). Not all devices will honor all (or even any) of these values. Use |
alert.android.lights.color | string | The LED color. |
alert.android.lights.on | number of milliseconds | How long should the LED stay on. |
alert.android.lights.off | number of milliseconds | How long should the LED stay off. |
alert.android.vibrate | boolean or array of integers | Should the notification vibrate using the default pattern, or the provided one. |
alert.android.sound | URL or resource identifier | Set the sound to play. It will be played using the default audio attributes for notifications. A notification that is noisy is more likely to be presented as a heads-up notification. |
alert.android.ongoing | boolean | Set whether this is an "ongoing" notification. Ongoing notifications cannot be dismissed by the user. |
alert.android.progress | boolean or 0 to 100 integer | Set the progress this notification represents. The platform template will represent this using a progress bar. Use |
alert.android.smallIcon | resource identifier | Set the small icon resource, which will be used to represent the notification in the status bar. The platform template for the expanded view will draw this icon in the left, unless a large icon has also been specified, in which case the small icon will be moved to the right-hand side. |
alert.android.largeIcon | URL or resource identifier | Add a large icon to the notification content view. In the platform template, this image will be shown on the left of the notification view in place of the small icon (which will be placed in a small badge atop the large icon). |
alert.android.buttons | array of objects | A list of up to 3 buttons to add to the notification in the notification center. |
alert.android.buttons[].label | string | The button label. |
alert.android.buttons[].icon | resource identifier | The icon to display next to the button label. |
alert.android.buttons[].targetUrl | URL | The content to open when clicking on the button, as an alternative to clicking on the notification itself. |
alert.android.buttons[].actions | array of actions | A list of background options to perform when clicking on the button. |
alert.android.allowSystemGeneratedContextualActions | boolean | Determines whether the platform can generate contextual actions for a notification. Android defaults this to true. |
alert.android.badgeIconType | string | Sets which icon to display as a badge for this notification. This value might be ignored, for launchers that don't support badge icons. One of:
|
alert.android.colorized | boolean | Set whether this notification should be colorized using This should only be used for high priority ongoing tasks like navigation, an ongoing call, or other similarly high-priority events for the user. For most |
alert.android.extras | object | Any extras to put on the system notification object. Android already puts some keys of its own. These extras can be retreived when listing active notifications in the system. |
alert.android.foreground | object | Permits to override any of the above options if the notification is displayed while the application is foreground. |
alert.android.foreground.priority | string | See |
alert.android.foreground.autoOpen | boolean | Whether to automatically do as if the user clicked the notification if received while in foreground. |
alert.android.foreground.autoDrop | boolean | Whether to automatically do as if the user swiped the notification if received while in foreground. |
HTML styling support is limited to about the following tags:
<br>
<h1>
<h2>
<h3>
<h4>
<h5>
<h6>
<b>
<i>
<u>
<big>
<small>
<strong>
<em>
<strike>
<sub>
<sup>
<a href="http://www.example.com">Link</a>
<div align="left|center|right">
<p dir="ltr|rtl">
<font size="24" color="red" face="Monospace">
<tt>
<blockquote>
<cite>
<dfn>
alert.web
alert.web
The following table presents the Web specific options that can be user in the alert.web
field:
Field | Type | Description |
---|---|---|
alert.web.dir | string |
|
alert.web.lang | string | The notification’s language specifies the primary language for the notification’s title, body and the title of each of its buttons. Its value is a string. The empty string indicates that the primary language is unknown. Any other string must be interpreted as a language tag. Validity or well-formedness are not enforced. |
alert.web.body | string | Text text to display in the notification. This is the Web specific name of the |
alert.web.icon | URL | The HTTPS URL of the icon to display next to the notification. |
alert.web.badge | URL | A small icon displayed when there is not enough space to display the notification itself. It may also be displayed inside the notification with less visual priority than the icon itself. |
alert.web.image | URL | The HTTPS URL of the big image to display below to the notification. |
alert.web.sound | URL | The sound to play. |
alert.web.vibrate | array of integer | The vibration pattern. |
alert.web.timestamp | timestamp in milliseconds | Indicates the time of the event for which the notification is shown. |
alert.web.renotify | boolean | Indicates if the user should get a visual notification after a notification has been updated. |
alert.web.silent | boolean | Indicates that no sounds or vibrations should be made. |
alert.web.noscreen | boolean | Indicates that the screen of the device should not be enabled. |
alert.web.requireInteraction | boolean | Indicates that on devices with a sufficiently large screen, the notification should remain readily available until the user activates or dismisses the notification. |
alert.web.sticky | boolean | Indicates that the end user should not be able to easily clear the notification. |
alert.web.buttons | array of objects | A list of buttons to add to the notification. |
alert.web.buttons[].label | string | The notification button label. |
alert.web.buttons[].action | string | The notification button identifier. An identifier is automatically generated if not specified. |
alert.web.buttons[].icon | URL | A small button icon to display next to the button label. |
alert.web.buttons[].targetUrl | URL | The URL of the page to show when clicking on that button, as an alternative to clicking on the notification itself. |
alert.web.buttons[].actions | array of actions | The optional list of actions that the button should perform. |
For more information, you can read the Notification API living standard, but beware, it's a bit dry.
Popups
The inApp
top-level field controls the popups shown to the user. The structure of a few types that are reused multiple times is described after.
If a Notification object has both an alert
and an inApp
field, then it represents a push notification that triggers a popup when clicked. If it only has an inApp
field, it represents a standalone popup.
Field | Type | Description |
---|---|---|
inApp.content | object with only 1 field. Mandatory | This object describes the type of popup and its content. It can contain only a single field, listed in the entries right below. |
inApp.content.banner | See below | Describes a popup of type banner. |
inApp.content.card | See below | Describes a popup of type card. |
inApp.content.imageOnly | See below | Describes a popup of type imageOnly. |
inApp.content.modal | See below | Describes a popup of type modal. |
inApp.content.webView | See below | Describes a popup of type webView. |
inApp.payload | object. Optional | Custom payload made available alongside the popup content. |
inApp.content.banner
inApp.content.banner
A banner popup is a small message with a title, text and small image, appearing on the top or bottom of the screen, before disappearing after a few seconds.
Field | Type | Description |
---|---|---|
inApp.content.banner.title | styledText. Mandatory | The title of the banner. Appears in bold above the body. |
inApp.content.banner.body | styledText. Optional | The body of the banner. Appears under the title. |
inApp.content.banner.imageUrl | URL. Optional | The image of the banner. Appears on the left of the title and body. |
inApp.content.banner.backgroundHexColor | hexColor. Optional | The color of the banner's background. |
inApp.content.banner.actions | array of actions . Optional | The actions to perform when the banner popup is clicked. |
inApp.content.banner.bannerPosition | "top" or "bottom" . Mandatory | The position of the banner. |
inApp.content.card
inApp.content.card
A popup with an image on top, followed by a title and a body and a primary button and optional secondary button. In portrait mode, the image is pulled left.
Field | Type | Description |
---|---|---|
inApp.content.card.title | styledText. Mandatory | The title of the card. Appears in bold above the body, under the image in portrait mode or right to it in landscape mode |
inApp.content.card.body | styledText. Optional | The body of the card. Appears below the title. |
inApp.content.card.portraitImageUrl | URL. Optional | The image of the card in portrait mode. Appears above the title and body. |
inApp.content.card.landscapeImageUrl | URL. Optional | The image of the card in landscape mode. Appears left of the title and body. |
inApp.content.card.backgroundHexColor | hexColor. Optional | The background color of the card. |
inApp.content.card.primaryActionButton | button. Mandatory | The primary button of the card. Appears in the lower right corner, right of the optional secondary button. |
inApp.content.card.secondaryActionButton | button. Optional | The secondary button of the card. Appears in the lower right corner, left of the primary button. |
inApp.content.card.primaryActions | array of actions . Optional | The actions to perform when the card's primary button is clicked. |
inApp.content.card.secondaryActions | array of actions . Optional | The actions to perform when the card's secondary button is clicked. |
inApp.content.card.entryAnimation | entryAnimation | The entry animation of the card. |
inApp.content.card.exitAnimation | exitAnimation | The exit animation of the card. |
inApp.content.imageOnly
inApp.content.imageOnly
A popup consisting solely of a full-screen image.
Field | Type | Description |
---|---|---|
inApp.content.imageOnly.imageUrl | URL. Mandatory | The URL of the image to display. |
inApp.content.imageOnly.actions | array of actions . Optional | The actions to perform when the popup's image is clicked. They are not performed is the popup is dismissed by clicking outside of the image boundaries. |
inApp.content.imageOnly.closeButtonPosition | "inside" , "outside" or "none" . Optional | The position of the close button. If choosing "inside" , the button will appear above the image in the top right corner. |
inApp.content.imageOnly.entryAnimation | entryAnimation | The entry animation of the image. |
inApp.content.imageOnly.exitAnimation | exitAnimation | The exit animation of the image. |
inApp.content.modal
inApp.content.modal
A modal popup with a title, optional image and body, with a single optional button.
Field | Type | Description |
---|---|---|
inApp.content.modal.title | styledText. Mandatory | The text of the modal. Appears in bold above the image and body. |
inApp.content.modal.body | styledText. Optional | The body if the modal. Appears below the image and title. |
inApp.content.modal.imageUrl | URL. Optional | The image of the modal. Appears below the title and above the body. |
inApp.content.modal.actionButton | button. Optional | The button of the modal. |
inApp.content.modal.backgroundHexColor | hexColor . Optional | The background color of the modal. |
inApp.content.modal.actions | array of actions . Optional | The actions to perform when the modal's button is clicked. |
inApp.content.modal.closeButtonPosition | "inside" , "outside" or "none" . Optional | The position of the close button. Mandatory if there is no button. |
inApp.content.modal.entryAnimation | entryAnimation | The entry animation of the modal. |
inApp.content.modal.exitAnimation | exitAnimation | The exit animation of the modal. |
inApp.content.webView
inApp.content.webView
A very flexible popup format consisting of an HTML content displayed in a web view that is full-screen by default, but can shrink to adapt to the displayed content.
It is strongly recommended that you completely read the Providing content and style for your Popup article of our documentation, and the Popup SDK reference, in order to properly and fully take advantage of this powerful format.
Field | Type | Description |
---|---|---|
inApp.content.webView.url | URL. Mandatory if field .html is missing. | The URL of the content to display. If the .html field is used, this field is populated server-side to hosted version of the given HTML and CSS content. You can use this field without .html and .css to point to an existing content. |
inApp.content.webView.html | string. Mandatory if field .url is missing. | HTML source of the content to display. Either this field or the .url field is mandatory. Both fields cannot be used together. |
inApp.content.webView.css | string. Optional | CSS source to be injected inside the HTML before display. This is only provided as a convenience. |
inApp.content.webView.closeButtonPosition | "inside" or "none . Optional | The position of the close button. |
inApp.content.webView.entryAnimation | entryAnimation | The entry animation of the popup. |
inApp.content.webView.exitAnimation | exitAnimation | The exit animation of the popup. |
Popup hexColor
schema
hexColor
schemaThis is a string representing a CSS color code in #RRGGBB
hexadecimal format.
Examples: #000000
is black, #FF0000
is red, #00FF00
is green, #0000FF
is blue, and #FFFFFF
is white.
Popup styledText
schema
styledText
schemaField | Type | Description |
---|---|---|
.text | string. Mandatory | The text to display. Mandatory. |
.hexColor | hexColor. Optional | The color of the text. |
Popup button
schema
button
schemaField | Type | Description |
---|---|---|
.text | styledText. Mandatory | The text of the button |
.buttonHexColor | hexColor. Optional | The color of the button background. |
Popup entryAnimation
schema
entryAnimation
schemaOne of the following strings:
fadeIn
slideInFromRight
slideInFromLeft
slideInFromTop
slideInFromBottom
Popup exitAnimation
schema
exitAnimation
schemaOne of the following strings:
fadeOut
slideOutRight
slideOutLeft
slideOutUp
slideOutDown
Push options
Field | Type | Description |
---|---|---|
push.payload | object | Custom payload to merge with the notification payload itself. |
push.custom | object | A key value mapping of custom data to give in the notification payload under the |
push.expirationDate | timestamp in milliseconds, or a string date using format | The date after which the notification should be dropped if not already delivered to a user's device. |
push.expirationTime | duration in milliseconds, or something like "10 minutes" | The duration after which the notification should be dropped if not already delivered to a user's device. |
push.priority | string |
|
push.receiveActions | array of actions | An optional list of background actions to perform when the SDK receives the notification. |
push.android | object | You can override any of the above keys for Android devices. |
push.android.delayWhenIdle | boolean | Indicates whether the message should not be sent until the device becomes active. |
push.android.collapseKey | string | This parameter defines a group of messages that can be collapsed, so that only the last message gets sent when notifications can be delivered to a device anew. |
push.android.restrictedPackageName | string | This parameter specifies the package name of the application where the registration tokens must match in order to receive the message. |
push.ios | object | You can override any of the above keys for iOS devices. |
push.ios.collapseId | string | Multiple notifications with the same collapse identifier are displayed to the user as a single notification on iOS 10+. The value of this key must not exceed 64 bytes. |
push.web | object | You can override any of the above keys for Web devices. |
push.web.topic | string | Collapsing multiple push messages with the same topic server-side, that is before they are delivered. |
Available actions
for notification and popups clicks and buttons
actions
for notification and popups clicks and buttonsEach action is composed of a type
field, and any additional fields required by the chosen type.
We present below one table per supported action type.
Field | Valid for | Type | Description |
---|---|---|---|
.type | All | string |
|
.event |
| object | The event that should be tracked. |
.event.type |
| string | The event type, like the first argument of the |
.event.custom |
| object | Optional custom data to attach to the event payload. |
.installation |
| object | New data to merge to the installation. Only the |
.custom (deprecated) |
| object | Use |
.tags |
| array of strings | The list of tags to add or remove. |
.method |
| string | The callback method name. |
.methodArgs |
| string | The callback argument value. |
.url |
| string | The URL or deeplink to open. |
.tag |
| string or | Selects notifications with the given tag (or without tag if Note that Android also supports these platform-specific fields:
Note that iOS also supports these platform-specific fields:
|