Try OpenEdge Now
skip to main content
Online Help
Data Object overview : Tasks : Using the push notification API : Creating notifications with device filtering criteria
Creating notifications with device filtering criteria
The OpenEdge.Mobile.PushNotificationMessageBuilder class enables you to create customized notifications. You can create notifications with a device filtering criteria and send messages only to certain devices. You can use various filtering criteria like physical device, user, or geographic location.
You can use the OpenEdge.Mobile.PushNotificationMessageBuilder class to perform the following operations:
1. Call the Send() or Schedule() method
2. Add the filtering criteria
3. Retrieve the completed payload using the Payload property.
The example below illustrates the SendNotification() and ScheduleNotification() methods using the OpenEdge.Mobile.PushNotificationMessageBuilder class.
define variable oPayload as JsonObject no-undo.

/* Message builder equivalent of SendNotification() method */
assign oPayload = PushNotificationMessageBuilder
:Send(cMessage, iBadgeCount)

/* Message builder equivalent of ScheduleNotification() method */
assign oPayload = PushNotificationMessageBuilder
:Schedule(cMessage, iBadgeCount)
:At(add-interval(now, 1, 'hour'))

/* Perform the send */
The push notification server, by default, provides support for the following basic filters:
Enables you to choose specific devices to which the notifications are sent using the OnDevice, NotOnDevice, IncludeDevice, and ExcludeDevice methods. These methods filter the devices by device ID (character).
Classifies devices by channel using the IncludeChannels, ExcludeChannels, and MatchChannels methods. These methods use a JsonArray argument.
Note: Channels is a predefined array column.
Classifies devices based on platforms: Android and iOS. The OnPlatform, NotOnPlatform, IncludePlatform, and ExcludePlatform enable filtering the devices by platform. These methods use the OpenEdge.Mobile.ApplicationPlatformEnum parameter.
Note: For detailed information about other types of filtering capabilities provided, see Telerik PUSH notifications.
The below example illustrates sending messages to the three specified devices.
/* send to specific devices */
define variable cDeviceId as character extent 3 no-undo.

assign cDeviceId[1] = '<first-device-id>'
cDeviceId[2] = '<second-device-id>'
cDeviceId[3] = '<third-device-id>'.

assign oPayload = PushNotificationMessageBuilder
:Send(cMessage, iBadgeCount)

/* Perform the send */
The OpenEdge.Mobile.PushNotificationMessageBuilder class provides API for adding filter criteria on any column. The supported data types for the columns are:
Each data type has its own Add<type>Filter() method, which uses the following parameters:
Filter name
A character expression that matches the column name.
Filter value
A value based on which the devices are filtered.
Note: The type of data required depends on the filter type. For instance, an Array filter requires an instance of a JsonArray object; a String filter requires a character value.
Operand (such as Equals or Includes)
Operands represented by the OpenEdge.Mobile.PushNotificationFilterOperandEnum enumeration.
Note: Different data types support different operands. For instance, a Geo filter supports Near, NearSphere, and Within but not Equals or Includes.