6

If I want to have a service in my android app that listens from Firebase if a child has been added to the signed user friend's request, does it affect the battery or the CPU of the users? I yes, should I consider finding another solution? I plan to have 3 other listeners in the background as well. Thanks.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

3

This is a pattern you should avoid because:

1) The device may disconnect the network from your Android app in doze mode in newer versions of Android. If you're trying to get notified at any time of any change, this is not going to work.

2) Firebase Cloud Messaging is a better way to reliably wake a device to handle a change that your app needs to know about.

Firebase Realtime Database uses a websocket to let a client know when things change. At least the drain on battery from an open socket is not a big deal. You just shouldn't count on that connection unless your app is visible and has a reliable network connection.

Community
  • 1
  • 1
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441