Try OpenEdge Now
skip to main content
Online Help
Data Object overview : Tasks : Using the push notification API : Sending and scheduling notification messages
 
Sending and scheduling notification messages
The push notification service provides the following methods for sending and scheduling notification messages:
*SendNotification(): sends a notification message immediately
*ScheduleNotification(): sends a message at a specified time in the future
The SendNotification() and ScheduleNotification() methods each contain a message text and a badge count (only valid for iOS), and return a NotificationServiceError in the event of an error. They send notifications to all registered devices.
The below example builds on the example in Connecting to a push notification server and illustrates the SendNotification() and ScheduleNotification() methods.
define variable cMessage as character no-undo.
define variable iBadgeCount as integer no-undo.
define variable tSendAt as datetime-tz no-undo.

assign cMessage = 'App users should know this fact'.

/* send immediately */
oPushService:SendNotification(cMessage, iBadgeCount).

/* send in an hour's time */
assign cMessage = 'App users should know this fact, but not right now'
tSendAt = add-interval(now, 1, 'hours').

oPushService:ScheduleNotification(
cMessage,
iBadgeCount,
tSendAt,
true). /* use device time zone? */

catch eNSE as NotificationServiceError:
message
string(eNSE:GetErrorMessage())
view-as alert-box title 'NotificationServiceError'.
end catch.
The OpenEdge.Mobile.TelerikPushNotificationAdmin API also enables you to modify or delete notifications, send normal push notifications.