Android
User identifiers
In order to find a user to whom you need to send a notification, it is possible to specify one or several available identifiers:
Property | Type | Description |
token | string | Push token. If you use push token, all fields with other identifiers will be ignored! |
advertisingId | string | Advertising ID |
androidId | string | Android ID |
serialId | string | Serial ID |
userId | string | User id is applicable if an internal identifier (cross-platform user identifier) is used in your app. |
devtodevId | number | Numeric user identifier in devtodev database. |
Notification settings
The object of a message for the Android platform contains 2 fields:
payload (object) - describes the main content of a notification
options (object) - describes the optional settings of notification delivery
Notification content settings ("payload” object)
Property | Type | Description |
title | string | A short string describing the purpose of a notification. |
text | string | The text of an alert message. |
data | object | Optional if notification is not hidden. You can pass custom parameters with messages and use them within an app. For instance, you can activate advertising campaign or any other functionality for a user who has received this message. Example:
|
small_icon | string | Optional. You may use an icon from resources of your app. You should use resource name of the icon in this field. |
color | string | Optional. The parameter recolors the small icon of an app displayed in a notification in the specified color ("#RRGGBB"). This N parameter on Android also recolors the name of an app and texts on notification buttons. Example:
|
icon | string | Optional. Use the URL to a notification icon or a resource name. |
image | string | Optional. The value is image URL. Images should be ≤ 450dp wide, ~2:1 aspect. The image will be center cropped. |
sound | string | Optional. A media file to play in place of a default sound. If a sound file doesn’t exist or default is specified as the value, the default notification sound is played. The audio must be in one of the audio data formats that are compatible with system sounds. Supports “default” or the filename of a sound resource bundled in an app. Android sound files must reside in /res/raw/ If the option is not used, a notification comes silently. |
badge | int | Optional. This property was added in Android O. The value of the badge on the home screen app icon. If not specified, the badge is not changed. If set to 0, the badge is removed. |
vibration | boolean | Optional. In case of "true" during notification delivery a device will vibrate (if permission VIBRATION is received) |
led_color | string | Optional. LED hex color ("#RRGGBB"), a device will do its best approximation. Example:
|
action | object | Optional. The action after a click on the body of a notification. By default, a click opens an app. It is also possible to perform the following actions:
Examples:
|
interactive | object | Optional. It is possible to specify an array of notification buttons in an “interactive” object. Each button should contain the following properties:
Example:
|
Notification delivery and display settings ("options" object)
Property | Type | Description |
hidden | boolean | Switching the notification to the hidden mode. If “true” - a notification will not be displayed to a user, but will be transferred to an app. Such a message must not contain any properties except data in the “payload” object. |
priority | string | Optional. The priority of a notification. Default value is "normal". Specify one of the following values:
|
expire | number | This option identifies the date when a notification is no longer valid and can be discarded. It is possible to use either relative time in seconds passed since the moment of sending, or specify an exact date in UNIX epoch format expressed in seconds (UTC). Default value is 7 days (604800 seconds) after sending. Max. relative value for Android platform is 2 419 200 seconds (4 weeks). Keep in mind that an "expire" value of 0 means messages that can't be delivered immediately will be discarded. However, as long as such messages are never stored, this provides the best latency for sending notifications. |
collapse_key | string | Optional. Notifications are not collapsible by default. If multiple messages are sent with this key, the most recent message will suppress all previous unread messages with the same key. Collapsible messages are a better choice from a performance standpoint provided your application doesn't need to use non-collapsible messages. However, if you use collapsible messages, remember that GCM only allows a maximum of 4 different collapse keys to be used by the GCM connection server per registration token at any given time. You must not exceed this number, or it could cause unpredictable consequences. |
channel_id | string | Optional. The notification's channel id (this property was added in Android O). The app must create a channel with this ID before any notification with this key is received. If you don't send this key in the request, or if the channel id provided has not yet been created by your app, devtodev SDK uses the channel id specified by default ("channel_id": "_devtodev" - name: General notifications). |
badge_icon_type | int | Optional. This property was added in Android O (API level 26). 0 - Default. If this notification is being shown as a badge, always show as a number. 1 - If this notification is being shown as a badge, use the getSmallIcon() to represent this notification. 2 - If this notification is being shown as a badge, use the getLargeIcon() to represent this notification. |
Examples
Visible push notification
POST
Hidden push notification
POST
Last updated