Bondi logo

The Bondi push Module - Version 0.3

February 2010

Authors


Abstract

BONDI Push API

Table of Contents


Summary of Methods

Interface Method
SubscriptionSuccessCallback void onSuccess(unsigned long subscriptionID)
PushEventCallback void onPushEvent(PushMessage message)
PushManager PendingOperation subscribe(SubscriptionSuccessCallback successCallback, ErrorCallback errorCallback, PushEventCallback listener, DOMString registrationUri, DOMString accept, DOMString appid, boolean exclusive)
void unsubscribe(unsigned long subscriptionID)
PushMessage DOMString getAllMessageHeaders()
DOMString getMessageHeader(DOMString header)

1. Introduction

This API provides functionality of OMA Push delivery to Web Applications running in the widget context, which includes; subscription/unsubscription of web applications to Push messages from the OMA Push enabler, and delivery of received Push messages to the subscribeed application(s).

This module offers the functionality to subscribe to OMA Push messages. A subscription to Push messages will remain active until explicit unsubscription. While subscribed, Push messages that match application preferences will be delivered to the application if possible, through a call to the application-defined Push message listener.

The basic structure of OMA Push messages is very similar to HTTP messages, i.e. they include headers and a content body.

Headers:

Content:

OMA Push messages are delivered via various bearers and protocols, depending upon the support of the specific device. The specific bearer used is transparent to the application, except as arranged through a specific Push Registration URI (a parameter of the subscription process).

The latest OMA Push Candidate Enabler release is OMA Push 2.3. OMA Push "Over-the-Air" protocol reference: Push-OTA

1.1. Feature set

This is the URI used to declare this API's feature set, for use in bondi.requestFeature. For the URL, the list of features included by the feature set is provided.

http://bondi.omtp.org/api/push

All the Push features

Includes API features:

  • http://bondi.omtp.org/api/push.subscribe

1.2. Features

This is the list of URIs used to declare this API's features, for use in bondi.requestFeature. For each URL, the list of functions covered is provided.

http://bondi.omtp.org/api/push.subscribe

Subscribe for access to Push messages

Device capabilities:

  • push

1.3. Device capabilities

push

Subscribe for access to Push messages

Security parameters:

  • appid: Push Application ID to be subscribed to. The parameter can be used to restrict access to events meant for certain application types, e.g. OMA-standardized Push applications (browsing, Multimedia Messaging (MMS), Instant Messaging (IM), Device Management (DM), etc.) by blocking subscription to appid values prefixed by "x-wap" or "x-oma".
  • accept: Content (MIME) types to be subscribed to. The parameter can be used to restrict access to content intended for a specific pre-define handler, e.g. OMA-standardized Push applications (MMS notifications, IM notifications, DM notifications, etc) by blocking subscription to MIME types associated with those applications.
  • exclusive: Request exclusive subscription to the selected parameters. The parameter can be used to ensure that only a single application can act as a handler for the event types. Note that the user agent will deny exclusive subscription if that conflicts with device-native clients (e.g. browsing, MMS, IM, DM, etc).

2. Interfaces

2.1. SubscriptionSuccessCallback

The success callback for subscription to incoming Push messages.

        [Callback=FunctionOnly, NoInterfaceObject] interface SubscriptionSuccessCallback {
                void onSuccess(in unsigned long subscriptionID);
        };

This callback completes the asynchronous operation initiated by the subscribe() method, confirms successful subscription to the requested Push message events, and provides the subscription ID that can be used to cancel the subscription at a later time, via the unsubscribe() method.

Methods

onSuccess

Method invoked when subscribing is successful

Signature
void onSuccess(in unsigned long subscriptionID);
Parameters
  • subscriptionID: Identifier of the subscription

2.2. PushEventCallback

Push message callback

        [Callback=FunctionOnly, NoInterfaceObject] interface PushEventCallback {
                void onPushEvent(in PushMessage message);
        };

Callback for incoming Push messages. When the callback is invoked its input parameters are the Push message header array and content.

Methods

onPushEvent

Method invoked to notify about incoming Push message

Signature
void onPushEvent(in PushMessage message);
Parameters
  • message: The Push message

2.3. PushManager

Manager class exposed as the Push module API.

         interface PushManager {
                PendingOperation subscribe(in SubscriptionSuccessCallback successCallback, 
                                in ErrorCallback errorCallback,
                                in PushEventCallback listener,
                                [Optional] in DOMString registrationUri,
                                [Optional] in DOMString accept,
                                [Optional] in DOMString appid,
                                [Optional] in boolean exclusive)
                        raises(SecurityError, DeviceAPIError);

                void unsubscribe(in unsigned long subscriptionID)
                        raises(SecurityError, DeviceAPIError);
        };

This manager class exposes the Push base API, such as subscribing to OMA Push message events, delivering received Push message events, and unsubscribing to Push message events.

Code example
  var subscriptionID = 0;

        // Define the success callback to get the subscription ID.
        function successCallback(id) {
                subscriptionID = id;
        }

        // Define the error callback.
        function errorCallback(response) {
                alert( "Push subscription failed. The error code is: " +  response.code);
        }

        // Define listener for received Push messages
        function gotPush(push) {
                var ctype = push.getMessageHeader("Content-Type");
                if (ctype == "text/vnd.wap.si") {
                        serviceIndication(push.messageXML);
                }
                if (ctype == "text/vnd.wap.sl") {
                        serviceLoad(push.messageXML);
                }
                (... etc for other content types as supported by widget)
        }

        // Subscribe to Push messages
        var accept = "text/vnd.wap.si";
        var appid = "x-oma-application:dcd.ua";
        var pendop = bondi.push.subscribe(successCallback, errorCallback, 
                        gotPush, registrationUri, accept, appid, false);

        // Cancel subscription to Push messages
        bondi.push.unsubscribe(subscriptionID);

 

Methods

subscribe

Method for subscription to Push events.

Signature
PendingOperation subscribe(in SubscriptionSuccessCallback successCallback, in ErrorCallback errorCallback, in PushEventCallback listener, in DOMString registrationUri, in DOMString accept, in DOMString appid, in boolean exclusive);

This API allows applications to be notified whenever an incoming Push meets a set of conditions. The returned identifier may be used to unsubscribe from these events using the unsubscribe method.

The accept is optional, and can be used by the widget to request notification for specific content (MIME) types only.

The callback argument is mandatory. Whenever a Push message is received the system will call the supplied callback passing the Push message object.

If the widget is not authorized to subscribe for Push messages, a SecurityError with code PERMISSION_DENIED_ERROR will be raised.

If the implementation has not implemented the API, a DeviceAPIError with code NOT_SUPPORTED_ERROR will be raised.

Parameters
  • successCallback: function called when the invocation ends successfully, use response object to retrieve subscription identifier
  • errorCallback: function called when an error occurs, the callback provides an input parameter that is an Error object
  • listener: Callback to be invoked whenever an applicable Push message is received.
  • registrationUri: The address to which the Push Service Registration procedure [OMA PushOTA] should be executed, e.g. to receive applicable connection profiles for the Push service.
  • accept: The set of content (MIME) types for which the widget should be notified. Case-insensitive.
  • appid: The OMNA-registered or unregistered Push Application ID URN associated with the web application. Case-insensitive.
  • exclusive: Allows a widget for requesting exclusive subscription for the notifications. If set to true no other application could subscribe to these notifications.
Return value
PendingOperation enabling the requester to cancel this request.
Exceptions
  • SecurityError:

    PERMISSION_DENIED_ERROR when access is denied by the security policy, or the request is not possible otherwise (e.g. an exclusive subscription already exists or the appid/accept type is associated with a native client which has exclusive access to the type of Push messages).

  • DeviceAPIError:

    NOT_SUPPORTED_ERROR if the the implementation has not implemented the API.

Code example
        var pendop = bondi.push.subscribe(successCallback, errorCallback, 
               gotPush, registrationUri, accept, appid, false);
     
unsubscribe

Method to unsubscribe to Push message notifications.

Signature
void unsubscribe(in unsigned long subscriptionID);
Parameters
  • subscriptionID: Subscription identifier
Exceptions
  • SecurityError:
  • DeviceAPIError:

    INVALID_ARGUMENT_ERROR if an invalid parameter is provided to this function

Code example
 // "subscriptionID" is the ID returned upon subscription success.
  bondi.push.unsubscribe(subscriptionID);
 

2.4. PushMessage

Push Message API

        interface PushMessage {

                 DOMString getAllMessageHeaders();
                 
                 DOMString getMessageHeader(in DOMString header);

                 readonly attribute DOMString messageText;
                 
                 readonly attribute Document messageXML;
        };

The Push Message interface enables access to the headers and content of a Push message. The interface provides access to the headers as an array or to a specific header (by name), and to the message content as a string or XML document.

Attributes

readonly DOMString messageText

Get Push message content as text.

The messageText attribute returns the text response entity body (if any), as defined for XMLHttpRequest in http://www.w3.org/TR/XMLHttpRequest/#text-response-entity-body.

This is a readonly property.

Code example
 // "push" is set to a Push message object received earlier.
  alert(push.messageText); // show the Push message
 
readonly Document messageXML

Get Push message content as XML.

The messageXML attribute return the XML response entity body (if any), as defined for XMLHttpRequest in http://www.w3.org/TR/XMLHttpRequest/#xml-response-entity-body.

This is a readonly property.

Code example
 // "push" is set to a Push message object received earlier.
 var dcdXml = push.messageXML; // get the message as XML
 // get the channel metadata attribute
 var cm = getElementAttributes(dcdXml,"Channel-Metadata",0);
 

Methods

getAllMessageHeaders

Get all headers of the Push message.

Signature
DOMString getAllMessageHeaders();

The getAllmessageHeaders() method returns all the Push message headers, as a single string, with each header line separated by a U+000D CR U+000A LF pair, and with each header name and header value separated by a U+003A COLON U+0020 SPACE pair. If there are no headers, the method returns null.

Code example
 // "push" is set to a Push message object received earlier.
  var headers = push.getAllMessageHeaders();
  alert(headers); // show the Push message headers 
 
getMessageHeader

Get a specific header of the Push message.

Signature
DOMString getMessageHeader(in DOMString header);

The getMessageHeader(header) method returns one of:

  • If header is an ASCII case-insensitive match for multiple message headers, the values of these headers as a single concatenated string separated from each other by a U+002C COMMA U+0020 SPACE character pair.
  • If header is an ASCII case-insensitive match for a single message header, the value of that header.
  • null.
Parameters
  • header: Name of the header to retrieve, if present. Case-insensitive.
Code example
 // "push" is set to a Push message object received earlier.
  var ctype = push.getMessageHeader("Content-Type");
  alert(ctype); // show the Push message content type