A client-side push-enabled app runs on a device and communicates, through the Push Service, with a server-side app, called a Push Initiator. Before you develop your own push-enabled app, you may find it helpful to try out the Push Capture sample app available on github.
To develop and test a push-enabled app, you need the following:
To test your push-enabled app, you need a Push Initiator. To develop the Push Initiator, you can use our Push Service SDK or another library of your choice. The Push Service SDK includes two sample Push Initiators that you may be able to use to test your push-enabled app.
The application ID and PPG URL for your Push Initiator
You get this information by email when you register your Push Initiator with BlackBerry. For more information about registering your Push Initiator, see Push Service and the Push Service Evaluation Form.
If you are using the push technology of the BlackBerry Enterprise Service only, you don't need to register.
BlackBerry 10 WebWorks SDK 2.0 or later
A BlackBerry 10 device with access to a wireless network
Add the Push Service plugins to your project
Adding a plugin copies the plugin to your project's plugins folder, and makes the APIs available to your app. It also adds the required <feature> element to your app's config.xml file. After you add a plugin, the contents of the plugin are packaged together with your other app resources the next time you build your app. You can add the plugins from the command line or with the SDK web tool.
To add the plugins from the command line:
- Open a command line in your app's project folder.
- Run the following
webworks plugin add com.blackberry.push webworks plugin add com.blackberry.invoked
To add the plugins using the SDK web tool:
- With your project open in the SDK web tool, in the navigation panel, click Plugins.
- In the Plugin Name or URL field, type com.blackberry.push, then click Add plugin
- Repeat the above step for the com.blackberry.invoked plugin.
Update your config.xml file
Before you can use the Push Service APIs with your app, you need to update your app's config.xml file with the following statements.
Add an entry for the invoke events that your app receives for push
<!-- config.xml --> <!-- Need to put an invoke entry here for push. --> <!-- The id here must match the invokeTargetId passed in --> <!-- one of the ops to blackberry.push.PushService.create. --> <rim:invoke-target id="sample.pushreceiver.invoke.push"> <type>APPLICATION</type> <filter> <action>bb.action.PUSH</action> <mime-type>application/vnd.push</mime-type> </filter> </rim: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.create() function. For more information about the invokeTargetID and PushService.create(), see Creating a PushService object.
Also note that the action tag is set to bb.action.PUSH. This value indicates that the invocation relates specifically to push messages. The event listener in the sample app also uses this value 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.
To allow your app to be opened from BlackBerry Hub
notifications, add the following statements.
<!-- config.xml --> <!-- Have an invoke entry here for when a notification is clicked <!-- on in the BlackBerry Hub. This will cause the app <!-- to be opened --> <rim:invoke-target id="sample.pushcapture.invoke.open"> <type>app</type> <filter> <action>bb.action.OPEN</action> <mime-type>text/plain</mime-type> </filter> </rim:invoke-target>
Note that the action tag is set to bb.action.OPEN. This value indicates that the invocation relates to an open invoke event. In the sample app, 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 app also uses this value 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.
Last modified: 2015-04-16