Would you like to tell us how we are doing?

You bet No thanks

Creating Push-Enabled Android Apps

If your Android app uses Cloud to Device Messaging (C2DM) or Google Cloud Messaging (GCM), when you repackage your app for the BlackBerry PlayBook, you can use the push technology of the BlackBerry Application Platform to provide similar functionality. Push technology gives your users immediate access to content, without waiting for downloads.

 

To create a push-enabled Android app, you need to:

  • Register with the Push Service.
  • Create the configuration file.
  • Specify push as a required permission in the .bar file's manifest file.
  • In the push initiator, the server-side application used to send out pushes, format the data to be sent to BlackBerry Application servers instead of Google application servers.

Registering with the Push Service

Before you can register to launch your app, you must first register for evaluation.

Creating the android.cfg file

After you register with the Push Service, you need to create a configuration file (the android.cfg file), which provides the BlackBerry Push configuration and will allow your Android app to work without changing any code or compiling again. Using any .zip utility, add the android.cfg file to the .bar file. You should do this before you sign the .bar package.

 

When you register for a Push Service, you receive a registration ID unique to your device. Registration IDs from Google are in the form of "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx", and BlackBerry registration IDs contain 8 characters. To differentiate between BlackBerry and Android devices on the application server, you can prefix the registration ID with the token prefix in the android.cfg file.

 

When you registered for the Push Service, you received a PPG Base URL and an application ID. In the converted .bar file, create a file named android.cfg and add the URL and app ID. Here is a sample android.cfg file:

<?xml version="1.0" encoding="utf-8"?> 
<android> 
   <push>
      <appid>some_appID</appid> 
      <ppgurl>http://cpXXX.pushapi.eval.blackberry.com</ppgurl> 
      <tokenprefix>bb-</tokenprefix>
   </push>
</android>
 

Here is a sample .bar file structure:

PushApp.bar/META-INFO/MANIFEST.MF
PushApp.bar/android/android.cfg 
PushApp.bar/android/PushApp.apk
PushApp.bar/android/res/drawable-hdpi/ic_launcher.png

Manifest permission

The Push Service requires that your signing keys have push capability enabled, and that push is specified as a required permission in the .bar file's manifest file. The required line is:

Entry-Point-System-Actions: _sys_use_consumer_push 

Server changes

With the C2DM and GCM services, the Google application servers sends push messages through a web request. BlackBerry Application Servers send push messages to the BlackBerry PlayBook through a similar web request. You must format your data before you send it to the Google application server. BlackBerry Push Service does not impose a format on the message, but because the message will be received by an Android app, you will need to format the data to the JSON format:

{ "key":"value", key2: value2, "key3": value3, key4 : "value 4" ... } 

Finally, your Push Initiator must send the data to BlackBerry Application Servers instead of Google application servers.

 

The Android Runtime will queue your pushes until the application is launched.