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.

Installation:

To use this API in your project, add the push plugin:

webworks plugin add com.blackberry.push

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].

Functions:
void acknowledge()
Properties:
Blob data
Object headers
String id
Boolean isAcknowledgeRequired

acknowledge()

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.

Synopsis:

void PushPayload.acknowledge(shouldAcceptPush)

Parameters:

shouldAcceptPush {Boolean}

True if the push should be accepted; false if the push should be rejected.

Example:

<script type="text/javascript">

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

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

</script>
            

data

The data (payload) of a push.

Synopsis:

readOnly
Blob PushPayload.data

Example:

                <script type="text/javascript">

// 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)

                </script>
            

headers

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

Synopsis:

readOnly
Object PushPayload.headers

Example:

<script type="text/javascript">

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

</script>
            

id

The ID of a push.

Synopsis:

readOnly
String PushPayload.id

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.

Synopsis:

readOnly
Boolean PushPayload.isAcknowledgeRequired

Last modified: 2014-04-10