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:
- Using Cloud Functions: Writing a database trigger on messages node in realtime database and send a notification to user.
- Background Service: Create a background service that listens for onChildAdded event on each conversation of a user.
- 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?