|
Techniques for Using the UP.Link Notification Libraries v3.0 from the UP.SDK
INTRODUCTION The UP.Link NotificationLibrary and API v3.1 includes functions that allow you to push cache operations directly to any UP.Link subscriber's phone. This allows applications to asynchronously remove decks from the UP.Browser cache, providing immediate synchronization of user data with your application database. Additionally, the library includes functions which allow you to discover the status of a notification, remove a pending notification, and remove an alert from a user's inbox. This technical note and companion sample application decribe how to send the following notification messages to the phone: -- Post an alertNOTE: The example code included with this technical note is written in HDML and Perl. It uses the COM version of the UP.Link Notification Library that ships with the UP.SDK v3.1. It is designed to run on the Windows platform only, and depends on Perlfor Windows and the UP.SDK Perl application utilities. For more information on sending notifications using the UP.Link Notification Library and API, please refer to Chapter 5 of the UP.SDK Developer's Guide, and Chapter 3 of the UP.SDK Tools and API Reference Guide The notify.cgi Source Code There are four local functions in the example application, each of which can be called to post a specifictype of notification message: The script is envoked by installing the notify.cgi script somewhere under your webserver doc root, and calling it with no arguments (i.e. localhost/up/scripts/notify.cgi). The notifications will workonly if you have your UP.Simulator set to UP.Link mode.If you try to use HTTP Direct with notify.cgi, all notifications will fail.NOTE: This exampleCGI script is written in Perl, and depends on the sample Perl utility libraries installed with the UP.SDK in the examples/apputils subdirectory as well as the notification COM object. Calling notify.cgi with no arguments will result in the control deck being returned. This deck presents the user with four choices: Send Alert, Send Alert + Invalidate, Send CacheOp,and Remove Alert. Each of the choices results in a different subroutine being called from the notify.cgi script. Send Alert calls Post Alert, SendAlert + Invalidate calls PostAlertInval, Send CacheOp calls PostCacheOp,and RemoveAlert calls RemoveAlert. PostAlert PostAlert sends an alert to the UP.Browser with a URL pointing to notify.cgi?DEMO=TIME. When the user views the alert, a deck is loaded which displays the current time and date. No cache information is sent with this deck, so if a user navigates back to the alert, the time shown is the time that the alert was first viewed. If the alert is posted again, the time that the alert was FIRST posted is displayed when the user views the alert. This is beause the URL associated with the alert, notify.cgi?DEMO=TIME, has been cached.The procedure for posting the alert is as follows: The OLE library is loaded use OLE;The COM Object is instantiated by calling $ntfn = CreateObject OLE 'Ntfn3Client.Ntfn3Client.1';Next the UP.Link to post to is set: $ntfn->NtfnSetHost($server); where $server is set based on the uplink through which the user is communicating as setby $ENV{'HTTP_X_UP_UPLINK'} The alert is posted $ntfn->NtfnPostAlert($subid, $url, $ttl, $alertType, $alertString, $strLen);where $subid is extracted from the HTTP Header as $ENV{'HTTP_X_UP_SUBNO'},the $url is ?DEMO=TIME, the $alertType is D--- (default alert), the $alertString is set to the title of the notification application, or notify.cgi in this case, and $stringLen is the length of the alertString. The server is queried for any errors: $result = $ntfn->NtfnGetLastResult(); And based on the $result,a success or error deck is returned. PostAlertInval PostAlertInvalidate, sends an alert to the UP.Browser with a URL pointing to notify.cgi?DEMO=TIME and also invalidates any cached version of this deck. The result is that everytime this alert is sent and the user views it, the current time is displayed. If the alert is revisited, the time that the alert was first viewed is displayed. The code and behavior for this method is nearly identical to that of the PostAlert method with the exception of the name of the COMinterface |