Update your bar-descriptor.xml file

Before you can use the Push Service APIs with your application, you need to update your application's bar-descriptor.xml file with the following statements. The sample application already has these statements, so you don't need to add them before using the sample application.

  1. If you are using the Push Service with the BlackBerry Internet Service, add a permission statement for the Push Service so that your application can work with push messages.
    <permission system="true">_sys_use_consumer_push</permission> 
  2. Add an entry for the invoke event that your application receives for a push message.
    <!-- bar-descriptor.xml -->
    <!-- Need to put an invoke entry here for push -->
    <!-- The id here must match the invokeTargetID in the -->
    <!-- net.rim.push.PushService constructor -->
    <invoke-target id="sample.pushreceiver.invoke.push">
        <type>APPLICATION</type>
        <filter>
            <action>bb.action.PUSH</action>
            <mime-type>application/vnd.push</mime-type>
        </filter>
    </invoke-target>

    Note the value for the invoke-target id. This value must match the invokeTargetID that's passed into the call to the PushService() constructor. For more information about the invokeTargetID and PushService() in the sample application, see Creating a PushService object.

    Also note that the action tag is set to bb.action.PUSH. This value indicates that the invoke relates specifically to push messages. The event listener in the sample application uses the InvokeAction.PUSH constant (which is equivalent to bb.action.PUSH) to check that the invoke event is a push message. For more information about the event listener and the push invoke event, see Receiving a push message.

  3. Add an entry for an open invoke event that your application receives.
    <!-- bar-descriptor.xml -->
    <!-- Have an invoke entry here for when a notification is clicked 
    in the BlackBerry Hub. This will cause the application to be opened. -->
    <invoke-target id="sample.pushreceiver.invoke.open">
        <type>APPLICATION</type>
        <filter>
            <action>bb.action.OPEN</action>
            <mime-type>text/plain</mime-type>
        </filter>
    </invoke-target>
    

    Note that the action tag is set to bb.action.OPEN. This value indicates that the invoke relates to an open invoke event. In the sample application, an open invoke event occurs when a user taps a notification for a push message in the BlackBerry Hub. The event listener in the sample application uses the InvokeAction.OPEN constant (which is equivalent to bb.action.OPEN) to check that the invoke event is an open invoke event. For more information about the event listener and the open invoke event, see Handling notifications in the BlackBerry Hub.