All Case Studies Design Development Interviews Our Way Project Management

How to Implement Android Notifications in Rails

Mobile notifications comprise a great feature for your app - especially when you integrate mobile and desktop solutions. Here's a quick guide on how to set up Android notifications in your Ruby on Rails project.


I assume you have some kind of user_id present in your app, ex. you are using Devise gem.


What You Will Use:

  • - a simple wrapper around Google Cloud Messaging API (GCM),
  • android project ID and API key - can be obtained here,
  • some android app that registers to GCM and sends registration id to backend API.


  • really simple to implement - no magic,
  • small library - 179 lines of code,
  • makes use of Google Cloud Messaging,
  • can be used both for Android and iOS (we tested only with Android).


  • Google Cloud Messaging might be not viable for you if you require very low latency - see Messenger case study.


Step 1

Add to Gemfile:

gem ‘gcm’

And run bundle install.


Step 2

Add API key to sec-config.yml:

  google_gcm_api: some1cool1key1here


Step 3

Now, we can make use of GCM and send some notifications. In the snippet below, you can find some example service object that takes registration IDs (that need to be pushed by mobile clients to your backend API) and a message hash which is just a message that will be included in the notification.


Step 4

Android clients need to listen to those notifications by using the broadcast receiver. What it will do with those notifications will depend on the business logic of your application. A sample code for such an application can be found here.

I hope you like it! If you have any comments or ideas how to improve it, please share them below.

Follow Netguru
Join our Newsletter

Read also
Need a successful project?
Estimate project or contact us
How to Implement Android Notifications in Rails