O'Reilly logo

Mastering Firebase for Android Development by Ashok Kumar S

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cloud Functions to fire a push notification

So far, we have explored features, functionalities, and so on. Now, it's the time to put all our learning into practice. In this example, we will use the blood bank project from Chapter 1Keep It Real – Firebase Realtime Database and add the notification feature using functions. Whenever the database has a new entry, meaning whenever people add their donor details, we will get a notification of what blood group has been added. 

  • Go to the Realtime Database chapter code. Open it in Android Studio.
  • Create the MessagingService class shown next. 
  • Register the service class in the manifest. 
  • Subscribe to the topic in the activity. 

Use this code for the MessagingService class:

package com.ashok.packt.realtime.database ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required