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:
TNtfnClientAPI--abstract base notification class. This class provides most of the API
TNtfnClient--concrete non-secure notification class
TNtfnSClient--concrete secure notification class
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:
ntfnscc.h and ntfnclnt.h header files in your code.
These files are provided in sdk_installdir/include/uplapi.
To send non-secure notifications, create a TNtfnClient object. To send secure or secure-preferred notifications, create a TNtfnSClient object.
LoadCertAndKey() to load the application certificate.
SetCharset() to set the character set.
TNtfnClientAPI methods, such as the PostAlert(), PostCacheOp(), and PostPrefetch()1 methods to send push and pull notifications.
GetNtfnStatus(), GetAlertStatus(), or GetPrefetchStatus() methods to check the status of notifications you have sent.
ClearPending(), DeleteNtfn(), DeleteAlert(), DeletePrefetch(), or RemoveAlertFromInbox() methods to delete (cancel) notifications that you no longer want to send.
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).
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:
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.
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.