[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Creating HDML Services that "Push" Information
Section 39 out of 67 total sections , Section 8 out of 11 sections in this chapter


Using the UNIX C++ Notification Library

The C++ Notification library is available on UNIX only. To send notifications from a C++ application on Windows, use the COM interface described in Using the COM Notification library to send notifications.

The C++ Notification library contains the following classes:

For complete documentation of these classes and their methods, see the UP.SDK Tools and APIs Reference.

To implement notifications with the C++ Notification API, follow these general steps:

  1. Include the ntfnscc.h and ntfnclnt.h header files in your code.
  2. These files are provided in sdk_installdir/include/uplapi.

  3. Create a notification object.
  4. To send non-secure notifications, create a TNtfnClient object. To send secure or secure-preferred notifications, create a TNtfnSClient object.

  5. If you are sending secure or "secure-preferred" notifications, call LoadCertAndKey() to load the application certificate.
  6. If the notification includes an alert with text that uses a character set other than UTF-8, call SetCharset() to set the character set.
  7. Use TNtfnClientAPI methods, such as the PostAlert(), PostCacheOp(), and PostPrefetch()1 methods to send push and pull notifications.
  8. Use the GetNtfnStatus(), GetAlertStatus(), or GetPrefetchStatus() methods to check the status of notifications you have sent.
  9. Use the ClearPending(), DeleteNtfn(), DeleteAlert(), DeletePrefetch(), or RemoveAlertFromInbox() methods to delete (cancel) notifications that you no longer want to send.
  10. Link your code with the Notification library.
  11. The library file is provided in sdk_installdir/lib/libntfns.a. This library file is not included in Windows versions of the UP.SDK.

The following sections provide simple examples of how to send notifications with the C++ library. For a complete example of UNIX C++ code that sends notifications, see sdk_installdir/examples/source/notify (only in the UNIX version of the UP.SDK).



Example: non-secure notifications

The following code constructs a non-secure client, using it to push a simple notification containing an alert. It then queries and deletes the notification:



Example: secure-preferred notifications

The following code constructs a secure-preferred client. The code to post, query, and delete a notification with this client is the same as for the preceding example.



Example: secure-only notifications

The following code constructs a secure-only client. The code to post, query, and delete a notification with this client is the same as for Example: non-secure notifications.


[Cover] [Previous Section] [Next Section] [Index]

Current chapter: Creating HDML Services that "Push" Information
Section 39 out of 67 total sections , Section 8 out of 11 sections in this chapter


1 To support backward compatibility with earlier UP.SDK versions, the notification library includes function names containing the terms "prefetch" and "alert". In the context of these function names, "prefetch" means "pull notification" and "alert" means "a push notification containing an alert".
Copyright © 1999, Unwired Planet, Inc. All rights reserved.