This API is part of the GeneXus built-in modules and provides a set of facilities for a GeneXus developer to send push notifications through an external notification provider. It allows registered device management and sending mechanisms for a single device or a group of devices.

Possible behaviors of the Appearance.Badge field of the Notification Structured Data Type (SDT) object.
| |
Value |
Description |
| |
None |
Leaves the badge count unaffected on the application icon. |
| |
SetTo |
Sets the badge count on the application icon to the number specified in the Badge field. |
| |
Increase |
Adds the Badge field number to the badge count on the application icon (a negative number will decrease it). |
Possible relational operators between keys and values.
| |
Value |
Description |
| |
Exists |
True when there exists a key defined. |
| |
NotExists |
True when a defined key does not exist. |
| |
Equal |
True when the key and value are equal. |
| |
NotEqual |
True when the key and value are not equal. |
| |
Greater |
True when the key is greater than the value. |
| |
Less |
True when the key is less than the value. |
FilterOperation
Possible binary logical operations.
| |
Value |
Description |
| |
OR |
At least one condition must be satisfied. |
| |
AND |
Both conditions must be satisfied. |
TargetType
Target alternatives for sending notifications.
| |
Value |
Description |
| |
Everybody |
Sends a notification to the default "All" segment of OneSignal. This means that every registered device will receive the notification. |
| |
Devices |
Sends a notification individually to each device using the OneSignal-specific API called CreateNotification. |
| |
Groups |
Sends a notification to the devices that have the specified TAG. This means that only registered devices that belong to a certain group receive the notification. The notification is filtered by OneSignal Tags, and the "CreateNotification Based on Filters" API is used. |
| |
Targets |
Sends a notification to devices that have the given TAG and meet certain filters. It is also resolved using OneSignal Tags, but in this case, filters can be applied to send the notification only to certain devices of a given TAG. |
Note: The OneSignal API does not allow sending notifications to
Segments created via the OneSignal Console. In addition, the OneSignal Free Plan has a limit of 2 TAGS.
PushNotificationPriority
The priority of the notification.
| |
Value |
Description |
| |
Normal |
Do not wake up the device if it is in doze mode. |
| |
High |
Wake up the device if it is in doze mode. |
| Field |
Domain |
Description |
| ApplicationId |
Character(100) |
[OPTIONAL] Native Mobile main object name. |
| Properties (1) |
<collection> |
|
| |
Item |
ConfigurationProperty |
Sets a contextual property of Notifications Provider property dynamically. |
| Debug |
|
|
| |
Debug |
Boolean |
Enables a debug mode for inspecting messages through a proxy server.
Default: False |
| |
Proxy |
Substructure |
|
| |
|
Host |
Character(20) |
Server name or IP for the proxy. |
| |
|
Port |
Numeric(6.0) |
Server port number. |
| Advanced |
Substructure |
|
| |
BackCompatibility |
Boolean |
Enables compatibility mode for Android/iOS older versions.
Default: False |
| Field |
Domain |
Description |
| PropertyName |
Character(100) |
The property name.
For example,
- OneSignal - App ID property must be "APP_ID"
- REST API Key property must be "REST_API_KEY" |
| PropertyValue |
<collection> |
The property value associated with that property name. |
| Field |
Domain |
Description |
| Priority |
PushNotificationPriority |
(Android-only)
Indicates the priority of the notification.
Default: High |
| Expiration |
Numeric(18.0) |
Time in seconds that the notification provider tries to send the message.
Default: 0 (no expiration) |
| Field |
Domain |
Description |
| Name |
Character(100) |
Name of the event defined in the Native Mobile main object, which receives the notification. |
| Parameter |
<Collection> |
[OPTIONAL] Set of parameters sent with the notification. |
| |
Name |
Character(100) |
Name of a variable in the smart device main object that will be used as a parameter of the notification. |
| |
Value |
Character(100) |
Value for the parameter sent to the event on the client side. |
| Field |
Domain |
Description |
| DefaultText |
Character(100) |
Text used when there is any localized item. |
| Text |
<Collection> |
[OPTIONAL] Set of texts by languages (localized). |
| |
Language |
Character(100) |
Language name for which the text is written. (Supported Languages Names: Spanish, English, Portuguese, Chinese, Japanese, Arabic) |
| |
Text |
Character(100) |
Text written in the language defined above. |
| Field |
Domain |
Description |
| Id |
Character(20) |
[OPTIONAL] Assigns an identification to the sent notification and allows rewriting it if necessary by sending it again with the same Id. |
| Title |
LocalizedText |
The title content of the notification. |
| Text |
LocalizedText |
The text content (below the title) of the notification. |
| Appearance |
Substructure |
[OPTIONAL] UI customization. |
| |
Badge |
Character(4) |
(iOS-only)
A numeric character to set a badge in the application icon |
| |
BadgeType (2) |
NotificationBadgeType |
Behavior of the "Badge" field. It can be "None", "Set to", or "Increase" (in this case, negative values will decrease badge number). |
| |
Icon |
|
|
| |
|
Large |
Url |
(Android-only)
URL for an image resource that will be used. |
| |
|
Small |
Character(100) |
(Android-only)
Name of an Image object embedded in the KB used for a small icon in the notification.
Some restrictions apply; see the Notification Icon section in Images in Panels
The Android Asset Studio tool by romannurik may be useful. |
| |
Sound |
Substructure |
|
| |
|
Sound |
Boolean |
Enables the sound when the notification arrives at the end user.
Default: True |
| |
|
CustomSound |
Character(100) |
Name of a project-embedded custom sound.
This option is for advanced users. If it's empty, the app will use the default platform sound. |
| |
Channel |
Character(100) |
The Android Oreo Notification Category to send the notification under. |
| |
Picture |
Character(100) |
(Android-only)
Picture to display in the expanded view. Can be a drawable resource name or a URL. |
| Actions |
Substructure |
|
| |
DefaultAction |
Substructure |
Default action that will be executed on Notification Tapping. |
| |
|
Event |
Event |
Settings for the default action that will be executed when the end user taps the notification. |
| |
CustomUIActions |
<Collection> |
Typically, when a user receives a notification, there is only a single action available - tapping the notification. CustomUIActions allow more than one action to be taken on a notification, enabling greater interactivity within notifications. See example here |
| |
|
Event |
Event |
Configuration for the secondary action. |
| |
|
Id |
Character(20) |
Id for the custom secondary action. |
| |
|
Text |
LocalizedText |
Text shown with the option. |
| |
|
Icon |
Character(100) |
Name of an Image object in the KB. |
| Advanced |
Substructure |
|
| |
Attachment |
<Collection> |
(iOS-only) [OPTIONAL] Set of rich content (such as media, for example, videos in MP4 format). Must be a public URL resource. |
| |
|
Type |
Character(100) |
Any identifier for the resource (e.g., myvideo.mp4). |
| |
|
URL |
Url |
Link to the media resource. |
| |
Group |
Substructure |
(Android-only) [OPTIONAL]. For stacking Push Notification. |
| |
|
GroupId |
Character(100) |
Identifier for stacking notifications in the same box. |
| |
|
GroupMessage |
LocalizedText |
Text to be shown when more than one message in the same group arrives on the smart device. |
| |
Template |
Character(100) |
Use a template you setup in the One Signal dashboard. You can override the template values by sending other parameters with the request.
This option is useful to personalize many aspects of the notification message, such as icon, sound, color, priority, category, etc. directly from the dashboard.
The template is the UUID found in the URL when viewing a template in the One Signal dashboard. Example: be4a8044-bbd6-11e4-a581-000c2940e62c |
| Field |
Domain |
Description |
| TargetType |
TargetType |
Indicates the target devices, determining which of the following collections will be used. |
| Device |
<Collection> |
[OPTIONAL] Applies when TargetType = Devices |
| |
DeviceToken |
Character(500) |
The DeviceToken of the target device in the set. |
| Group |
<Collection> |
[OPTIONAL] Applies when TargetType = Groups, and the collection is understood as a disjunction of groups (joined with OR operators). |
| |
Name |
Character(100) |
Name of the group previously added with AddDeviceGroup Procedure object. |
| Filter |
<Collection> |
|
| |
Name |
Character(100) |
Name of a filter key previously added with AddDeviceTargetFilter Procedure object. |
| |
Value |
Character(100) |
Value associated with the filter key. |
| |
Relation |
FilterRelationType |
Relation that associates the Name or Name and Value fields.
Default: Exists. |
| |
Operator |
FilterOperation |
Relation of the current item condition with the next one (the last item ignores this field).
Default: AND |
Associates a set of groups or categories to which a device belongs.
| |
Parameters |
Configuration:SDT(Configuration), DeviceToken:Character(500), Groups:Collection(Character(20)) |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
RemoveDeviceGroups
Disassociates a set of groups or categories from a device.
| |
Parameters |
Configuration:SDT(Configuration), DeviceToken:Character(500), Groups:Collection(Character(20)) |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
AddDeviceTargetFilter
Associates a filter name/value with a device.
| |
Parameters |
Configuration:SDT(Configuration), DeviceToken:Character(500), FilterName:Character(20), FilterValue:Character(20) |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
RemoveDeviceTargetFilter
Disassociates a filter name/value from a device.
| |
Parameters |
Configuration:SDT(Configuration), DeviceToken:Character(500), FilterName:Character(20), FilterValue:Character(20) |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
SendEvent
Executes an event on a specific device with delivery preferences.
| |
Parameters |
Configuration:SDT(Configuration), DeviceToken:Character(500), NotificationEvent:Event, Delivery:Delivery |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
SendEventTargets
Executes an event on a set of target devices with delivery preferences.
| |
Parameters |
Configuration:SDT(Configuration), Target:Target, Event:Event, Delivery:Delivery |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
SendNotification
Sends a push notification to a specific device with delivery preferences.
| |
Parameters |
Configuration:SDT(Configuration), DeviceToken:Character(500), NotificationMessage:Notification, Delivery:Delivery |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
SendNotificationTargets
Sends a push notification to a set of target devices with delivery preferences.
| |
Parameters |
Configuration:SDT(Configuration), Target:Target, NotificationMessage:Notification, Delivery:Delivery |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
SetDeviceTargetMultipleFilters (3)
Associates a list of filters (name/value collection) with a device.
| |
Parameters |
Configuration:SDT(Configuration), DeviceToken:Character(500), FilterTags:Properties |
| |
Returns |
Messages:SDT(Messages), Success:Boolean |
This method is only valid for the OneSignal Notifications Provider.
Consider that the Native Mobile application's main object is called "MyApp" and that it has the following event defined:
Event 'NotificationAction'
msg(&msg,status)
EndEvent
Warning: The event defined in the main app (for example, 'NotificationAction') cannot contain any command, function or control that includes UI (such as msg, confirm, etc). Remember that these notifications can arrive while the device is locked, while the app is running in
background mode, or even when the app
not running. However, the developer can trigger UI actions if the app is running in
foreground mode, but first, the developer must check that state by using the
Interop.ApplicationState property.
Consideration: If you are generating for iOS and your main object is a Menu object, the event must be associated with an Action located under the Notifications node (not under the Actions node). To do so, you must first explicitly add the Notifications node by right-clicking on the node that displays the Menu name and selecting Add > Notifications. Then, right-click on the Notifications node and select Add > Action to create the action that will be associated with the event.
Finally, from the web backend, you can write a source code as follows:
Variables:
&TheNotification : Notification, GeneXus.Common.Notifications
&TheNotificationDelivery: Delivery, GeneXus.Common.Notifications
&TheNotificationConfiguration : Configuration, GeneXus.Common.Notifications
Source:
&TheNotification.Title.DefaultText = "GeneXus"
&TheNotification.Text.DefaultText = "Notification Provider API"
&TheNotification.Actions.DefaultAction.Event.Name = "NotificationAction" // Declared in the SD Main object
&TheNotification.Actions.DefaultAction.Event.Parameters.FromJson('[{"Name":"msg","Value":"Hello dear user!"}]')
&TheNotification.Appearance.Icon.Small = !"GX15IconKB"
&TheNotificationDelivery.Expiration = 3000
&TheNotificationDelivery.Priority = PushNotificationPriority.Normal
&TheNotificationConfiguration.ApplicationId = !"MyApp"
GeneXus.Common.Notifications.SendNotification(
&TheNotificationConfiguration,
DeviceToken, // Target device token
&TheNotification,
&TheNotificationDelivery,
&OutMessages,
&IsSuccessful
)
Then, when the above code is executed, the device will receive a notification like this:
| Android |
iOS |
 |
 |
If the end user taps it, the msg command will print the message "Hello dear user!" in the console.
If you want to send the previous notification to devices that have certain tags already defined, you can use the SendNotificationTargets procedure with the Target parameter.
Suppose you have added the tag 'User Type' with the value 'Student' throughout the AddDeviceTargetFilter procedure, for those devices that correspond to student users.
Now, to send a notification to those devices, use this code:
&TargetFilter = new()
&TargetFilter.Name = !'User Type'
&TargetFilter.Value = !'Student'
&Target.TargetType = TargetType.Targets
&Target.Targets.Add(&TargetFilter)
SendNotificationTargets(&NotificationConfiguration, &Target, &Notification, &NotificationDelivery, &Messages, &Success)
- The iOS platform always uses the image set in Apple Application Icon property as the notification icon, unlike Android that uses those set in the Android Notification Icon property and can use a different image for the notification message by the Appearance.Icon field on the Notification SDT.
- In iOS, if the developer wants to download content when the app is in background mode (e.g. a video attached to the notification), it is necessary to include the 'remote-notification' value to the Background Modes property.
- As of GeneXus 15 Upgrade 10, when the developer uses any of the Send methods with OneSignal provider, the Messages parameter will return one item with the response payload in a JSON string in its "description" field. This JSON includes the notification Id and the quantity recipients.
For example,
{"id":"5263x49t-ss31-436r-942k-638h111d9g2a","recipients":1}
- If the developer removes a device from the provider's console (for example, OneSignal), the device remains associated with the identifier provided by the provider. In this case, uninstall the application from the device and reinstall it in order to generate a new identifier in the provider platform.
- GeneXus 15 Upgrade 4 fixes an issue when using more than two filter targets in the Target SDT.
For more information, refer to SAC#41070.
- Since Android 13 (API 33) it is recommended to set the Device Registration Mode property to Manual and use the exo Permissions to request the notifications permission. Ref.: SAC #52694.
When sending a notification, the following error occurs:
Unknown error processing: Push Provider was not specified. Please set a Push Provider
Make sure the webapp folder includes the CloudServices.config file (specifically \WEB-INF\CloudServices.config) with a valid notification configuration. If you are running the process in batch mode, the input file should be located in the current working directory. For Java, the input file should be located where "System.getProperty("user.dir")" points to, as this property can be set to specify the directory where the input file is located.
Objects: Procedure object, Web Panel object, Work With for Web pattern
Generators: .NET, Java
This API is available as of GeneXus 15 Upgrade 3.
(1) Available as of GeneXus 15 Upgrade 9.
(2) Available as of GeneXus 15 Upgrade 11.
(3) Available as of GeneXus 16 upgrade 10.