
© 2009-2010 OMTP Ltd. All rights reserved. OMTP and OMTP BONDI are registered trademarks of OMTP Ltd.
BONDI Push API
SubscriptionSuccessCallback
PushEventCallback
PushManager
PushMessage
| 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) |
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
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.
All the Push features
Includes API features:
http://bondi.omtp.org/api/push.subscribeThis 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.
Subscribe for access to Push messages
Device capabilities:
pushpushSubscribe 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).
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.
onSuccessMethod invoked when subscribing is successful
void onSuccess(in unsigned long subscriptionID);
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.
onPushEventMethod invoked to notify about incoming Push message
void onPushEvent(in PushMessage message);
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.
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);
subscribeMethod for subscription to Push events.
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.
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).
NOT_SUPPORTED_ERROR if the the implementation has not implemented the API.
var pendop = bondi.push.subscribe(successCallback, errorCallback,
gotPush, registrationUri, accept, appid, false);
unsubscribeMethod to unsubscribe to Push message notifications.
void unsubscribe(in unsigned long subscriptionID);
INVALID_ARGUMENT_ERROR if an invalid parameter is provided to this function
// "subscriptionID" is the ID returned upon subscription success. bondi.push.unsubscribe(subscriptionID);
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.
readonly
DOMString messageTextGet 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.
// "push" is set to a Push message object received earlier. alert(push.messageText); // show the Push message
readonly
Document messageXMLGet 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.
// "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);
getAllMessageHeadersGet all headers of the Push message.
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.
// "push" is set to a Push message object received earlier. var headers = push.getAllMessageHeaders(); alert(headers); // show the Push message headers
getMessageHeaderGet a specific header of the Push message.
DOMString getMessageHeader(in DOMString header);
The getMessageHeader(header) method returns one of:
// "push" is set to a Push message object received earlier.
var ctype = push.getMessageHeader("Content-Type");
alert(ctype); // show the Push message content type