1

I'm using FCM for notifications when the app is not in use(in active), but what if user is in a One to One conversation with some one or a group chat is going on?

Is it preferable to go along with FCM notification only, like send FCM notification for all messages and if user is in the same activity just update the view, a huge number of conversation might happen that way, and huge amount of notification from a group.

Or should I implement anything else for that?

I did find out a couple of links

Implementing one to one and group chat in android

But polling might be huge resource intensive

Please suggest any other procedure. How does Whatsapp or any other chat messenger handles One to One chat?

Community
  • 1
  • 1
Ari
  • 1,296
  • 1
  • 18
  • 36

1 Answers1

1

You can make use of Firebase Realtime Database for this.

Keeping a listener open to the realtime database and updating the UI as needed, while the app is in foreground. Should the app be in background, use FCM to send a notification.

Having a listener open also keeps a socket though. But compared to polling, you get to use FCM instead when the app is in background.

You can try out the Firebase Friendly Chat CodeLab as a starting point.

AL.
  • 36,815
  • 10
  • 142
  • 281
  • Firebase is very costly for the database on a monthly basis. I have tried out upstream messages, even that s also using up the database I guess. Any other way or architecture? – Ari Oct 27 '16 at 15:41
  • @Ari Hmm. I think that Firebase was already a good call. But maybe making use of [GCM CCS](https://developers.google.com/cloud-messaging/ccs) is the one you're looking for? – AL. Oct 27 '16 at 15:56