Developing a push-enabled app

Before you develop your own push-enabled app, you may find it helpful to Explore the sample push-enabled app.

Requirements

To develop and test a push-enabled app, you need the following:

Item Requirement

Push Initiator

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.

Client-side library

BlackBerry 10 WebWorks SDK 2.0

BlackBerry device

  • BlackBerry 10 OS
  • Data plan with your wireless service provider that provides a connection to the Wi-Fi network or mobile network

Add the Push Service plugins to your project

Before you can use the Push Service APIs with your application, you need to add the following plugins to your project:
  • com.blackberry.push
  • com.blackberry.invoked

Adding a plugin copies the plugin to your project's plugins folder, and makes the APIs available to your application. It also adds the required <feature> element to your application's config.xml file. After you add a plugin, the contents of the plugin are packaged together with your other application resources the next time you build your application. To add the plugins:

  1. Navigate to the directory of the app project.
  2. Add the com.blackberry.push plugin using the following command:
    webworks plugin add com.blackberry.push 
  3. Add the com.blackberry.invoked plugin using the following command:
    webworks plugin add com.blackberry.invoked

Update your config.xml file

Before you can use the Push Service APIs with your application, you need to update your application's config.xml file with the following statements.

  1. Add an entry for the invoke events that your application receives for push messages.
    <!-- 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 invoke relates specifically to push messages. The event listener in the sample application 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.

  2. 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 application 
    <!-- to be opened -->   
     <rim:invoke-target id="sample.pushcapture.invoke.open">
     <type>APPLICATION</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 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 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: 2014-12-04



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus