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.
For a great sample app that demonstrates how to use the push APIs, see Push Capture.
There is also a very valuable developer guide for the Push Capture sample app that you can find here.
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 ID | BB5.0 | BB6.0 | BB7.0 | PB1.0 | PB2.0 | BB10 | Ripple |
<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
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 Sun Dec 30 2012 18:15:42 GMT-0500 (EST)