PushPayload

The PushPayload object provides access to the payload that has arrived as the result of a push. This object cannot be created by the new keyword. It is generated only by the system on receipt of a push notification.


Learning Resources:

Sample - Push Capture Sample that demonstrates how to use the BlackBerry Push API [BlackBerry on GitHub].
Developer Guide Guide for creating a Push Capture sample app [BlackBerry Developer Documentation].

Supported Platform(s)

- BlackBerry 10
View Supported Platform Table
APIBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
acknowledge           Y 
data           Y 
headers           Y 
id           Y 
isAcknowledgeRequired           Y 

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:

You must declare the feature element(s) below in your configuration document:

Feature IDBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
<feature id="blackberry.push" />           Y 
Permission Elements (PlayBook and BlackBerry 10+)
You must declare the permission element(s) below in your configuration document:
- <rim:permit system = 'true'>_sys_use_consumer_push</rim:permit>
Permits your consumer (public) application to use push. This permission is not needed to use enterprise push.

Functions


Properties

Blob data
Object headers
String id
Boolean isAcknowledgeRequired

Functions

void acknowledge (shouldAcceptPush : Boolean)


Sends an acknowledgement to the PPG indicating whether a push should be accepted or rejected. It is up to the application to determine whether to accept or reject a push message based on it own business rules. It is strongly recommended to accept or reject the push message as soon as possible otherwise the push message will automatically be considered rejected.

Use the isAckRequired property to determine whether or not calling acknowledge is required.


Supported Platforms
 - BlackBerry 10


Parameters
shouldAcceptPush True if the push should be accepted; false if the push should be rejected

Code Example:
if (pushPayload.isAcknowledgeRequired) {
   // Accept push
   pushPayload.acknowledge(true);

   // To reject the push, you would call: 
   // pushPayload.acknowledge(false);
}

Properties

readonly Blob data


The data (payload) of a push.


Supported Platforms
 - BlackBerry 10


Code Example:
// See the extractPushPayload function in the PushService 
// class for an example of how to convert the data   
// property from a Blob to a string (for plain text) 
// and to an ArrayBuffer (for binary)

readonly Object headers


The headers of a push in string header name-header value pairs.


Supported Platforms
 - BlackBerry 10


Code Example:
// To access a header value with the name "header-name":
var headerValue = pushPayload.headers["header-name"];

readonly String id


The ID of a push.


Supported Platforms
 - BlackBerry 10

readonly Boolean isAcknowledgeRequired


Indicates whether or not a developer must acknowledge the receipt of a push. True if an acknowledgement is required for the push; false otherwise.


Supported Platforms
 - BlackBerry 10

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 11 2013 14:51:09 GMT-0500 (EST)