Would you like to tell us how we are doing?

You bet No thanks

Creating Push-enabled Android apps

The Creating Push-enabled Android apps landing page.

When you repackage your app for BlackBerry 10 devices, you can use the push technology of the BlackBerry Application Platform. The BlackBerry Application Platform provides similar functionality to Google Cloud Messaging (GCM). Push technology gives your users immediate access to content that has been sent (pushed) to their device.

The Android Cloud to Device Messaging Framework (C2DM) has been officially deprecated. For more information, see Android Cloud to Device Messaging Framework.

The Google Play Services SDK is not supported on BlackBerry 10. If your app includes GCM services, you must set up your project to use the stand-alone GCM SDK.

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 app used to send out pushes), convert the data so that it's sent to the BlackBerry Application servers instead of the Google app servers.

Registering with the Push Service

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

Creating the android.cfg file

After you register with the Push Service, you must create a configuration file (the android.cfg file). This file provides the BlackBerry Push configuration, and allows your Android app to work without any code changes, or the need to recompile it again. Using any ZIP utility, add the android.cfg file to the .bar file. You must create this configuration file 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 eight characters. To differentiate between BlackBerry and Android devices on the app server, you can prefix the registration ID with the token prefix in the android.cfg file.

When you register for the Push Service, you also received a PPG Base URL and an app ID. In the repackaged .bar file, create a file named android.cfg, and add the URL and app ID.

Here's 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 GCM services, the Google app servers sends push messages through a web request. BlackBerry Application Servers send push messages to BlackBerry devices through a similar web request. You must convert your data before you send it to the Google app server. BlackBerry Push Service does not impose a format on the message. However, because an Android app receives the message, you must convert the data to the JSON format:

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

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

The Android Runtime queues your pushes until the app is started. For more information about the BlackBerry Push Service, see Push technology for the enterprise.



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

comments powered by Disqus