Home » Android » Better approach for implementing one-to-one notifications with Firebase

Better approach for implementing one-to-one notifications with Firebase

Posted by: admin November 1, 2017 Leave a comment

Questions:

I am working on a messaging app and using Firebase for all sort of Server side stuff. I was going to implement one-to-one notifications between user when they message each other and the app is in background. FCM does not directly supports one-to-one notifications but there are some other ways that could be implemented. I just wanted to have an opinion of which of them could be better. Following are few ways I have in mind:

  1. Using Cloud Functions: Writing a database trigger on messages node in realtime database and send a notification to user.
  2. Background Service: Create a background service that listens for onChildAdded event on each conversation of a user.
  3. Separate Node App: Write a separate node app using Firebase Admin SDK, host it on firebase server, trigger that node script each time a user sends a message, and then send send FCM notification to the user.

Which of these is better option and why?

Answers: