Integrating IBM MobileFirst Foundation 8.0-based Android applications with IBM Bluemix Push Services


Applications using the MobileFirst Foundation SDK can be integrated with Bluemix Push Services for the applications to receive notifications.
Follow the instructions in this blog post in order to integrate your Android application with the Bluemix Push Notifications service.

Learn more about IBM Bluemix Push Notificaitons service and IBM Bluemix Mobile Foundation service


  1. Running a MobileFirst Server either locally or Mobile Foundation service on Bluemix.
  2. Instance of IBM Bluemix Push Notification
  3. Push Notification instance created at step 2 should be configured with GCM credentials.
  4. Push Notification instance created at step 2 should contain few tags.

Setting up the Android application

For the purpose of this blog post, the [RememberMe Android sample application] is used. Download the sample application and follow the instructions in the file to setup and run the app.

Adding the IBM Bluemix Push Service SDK

With the application setup and working, we will add the push functionalities into the app using the IBM Bluemix Push Service SDK.

  • Open the build.gradle of the app (located at RememberMeAndroid/app)
  • Remove the existing dependency of the ibmmobilefirstplatformfoundation
  • Add the below dependencies:
    compile (''){  
      transitive = false
    compile ('') {
      transitive = true
      exclude module: 'okhttp'
    compile ""

Note: The okhttp module is bundled with both the MFP SDK and the Push SDK. This will cause runtime issues, and to avoid it exclude the module from the Push SDK dependencies.

Initializing the IBM Bluemix Push Service

Add the following code to the RememberMeApplication.onCreate() function. This code initializes the BMS Push Client and this needs to be called only once per application.

String appRoute = "<appRoute of your Push Notification instance>";
String appGuid = "<app GUID of your Pus Notification instance>";

try {
    appRoute , appGuid, BMSClient.REGION_US_SOUTH);
} catch (MalformedURLException e){

"<Client Secret of your Push Notification Instance");

For the application to listen for the notifications, add the below in the AndroidManifest.xml.

  • Add the following to the top of the manifest tag
<!-- Permissions -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- GCM Permissions -->
android:name="" />

android:name="" android:protectionLevel="signature" />
  • Add the following push intent service and listener service to the application tag
<!-- GCM Receiver -->
     <action android:name=""/>
     <category android:name="" />

<!-- MFPPush Intent Service -->
        <action android:name="" />

Implementing the Push Functionality using SDK

Note: You can choose to create a new button in the ProtectedActivity code for push related functionalities. For simplicity the instructions here reuse the “Get Balance” button as the “Push Registration” button. Modify the getBalance button in activity_protected.xml accordingly.

On a click of button, registration of the device and tags subscriptions would happen in this app. Call the Push SDK in the ProtectedActivity “on click” event of the button.

For more details on the SDK refer here

Sending the Notification

To send the notification, one can use the Push Notification dashboard on the IBM Bluemix. See the send API for more details on sending the notification.

Demo flow for blog post

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on May 09, 2019