Contents


Extend an Android app using the IBM Push Notifications service on Bluemix

Use Push notifications to send relevant content to mobile devices

Comments

Editor's note: This tutorial is an update to "Extend an Android app using the IBM Push for Bluemix cloud service" originally published in February 2014. It was written using the Bluemix classic interface. Given the rapid evolution of technology, some steps and illustrations may have changed.

You may already know about some of the benefits of Bluemix™, IBM's open platform for developing and deploying mobile and web applications. The many pre-built services in the mobile solutions in Bluemix make it easy to build and enhance applications.

In this tutorial, we'll extend an existing Android application using the Push Notifications service on Bluemix.

As introduced in the previous tutorial in this series, the BlueList application is a simple Android app. In this tutorial, we'll add the Push Notifications (invoked from a Node.js-hosted application) to the BlueList app, so that notifications are sent when a list is updated, and the list is updated on all devices when one of the devices updates the list in some way.

With the free services on Bluemix, you can get started writing and extending your own applications in no time!

Note: The sample code has been deprecated and is no longer supported.

What you'll need

Step 1. Open the mobile app

Log in to Bluemix and open the BlueList app you built in the previous tutorial.

Screen capture of the BlueList application built from the previous tutorial
Screen capture of the BlueList application built from the previous tutorial

Step 2. Run the mobile app to make sure it still works

  1. Open the app in Android Studio and build it.
  2. Run the app on your Android device or simulator.
  3. Add some items to the To Do List of your app. Remember to sync your list with the database on the cloud by pulling down the screen.
Screen capture of the BlueList application on a mobile                             device

Step 3. Check your data on the cloud

In Bluemix, select the Cloudant NoSQL DB service and click the Launch button to open the Cloudant dashboard.

Screen capture of the Clouding NoSQL DB service page
Screen capture of the Clouding NoSQL DB service page

Go to the todosdb database.

Screen capture of todos database showing the number of items synced to the database
Screen capture of todos database showing the number of items synced to the database

The items are already synced to the database.

Screen                             capture showing your Google API Project number and Google Cloud Message API Key
Screen capture showing your Google API Project number and Google Cloud Message API Key

Step 4. Add and enable the Push Notification

Get your Google API Project number and Google Cloud Message API Key.

Screen                             capture of the API credentials
Screen capture of the API credentials

Copy the API key you just created and the Google Project number (Sender ID) into the Push Notifications configuration dashboard.

Screen capture of the Push Notifications configuration dashboard
Screen capture of the Push Notifications configuration dashboard

Step 5. Test sending notifications from Bluemix

  1. Log in to Bluemix.
  2. From the Dashboard view, click your application.
  3. Click the Push service icon.
  4. Click the Notification tab.
  5. Choose the audience and fill in the Message text field with anything you want. Screen                             capture of the audience and text message fields
    Screen capture of the audience and text message fields
  6. Click SEND.
  7. Watch as your mobile device or emulator receives a push notification! Screen capture of notification message on a device
    Screen capture of notification message on a device

Conclusion

Extending your app using the Push service available in Bluemix should give you a sense of how easy it is to consume and integrate mobile data capabilities using Mobile services in Bluemix. So far in this series, you've used the Cloudant NoSQL DB service to store, delete, update, and query a list of objects stored on the cloud. You've also used the IBM Push Notifications service to refresh the list on all devices and send notifications when one of the devices updates the list in some way.


Downloadable resources


Related topics


Comments

Sign in or register to add and subscribe to comments.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Mobile development, Cloud computing
ArticleID=963626
ArticleTitle=Extend an Android app using the IBM Push Notifications service on Bluemix
publish-date=05032016