11

I am building an Android app that requires real time updates. My server is Firebase. Firebase is meant to receive its updated data when the user is connected to the server. I am very impressed with Firebase so far, however my concern is receiving the new data when the app is not active. I really do not want to try these ideas to find out they are a bad idea, for I am short on time. I am looking for suggestions and advice.

  • A service (example). Worried about battery consumption and going over my connection limit if users are always connected.
  • An AlarmManager to run a sync every X hours. Worried about not getting updates quickly enough.
  • Using GCM push notification to send a tickle. Worried about paying for another service.

Any other suggestions or possible issues I missed? Thanks for your time!

Edit

I found this thread. Still unsure. Maybe a service is not a bad idea, per James Tamplin (Suspect he is Firebase dev)

Chad Bingham
  • 32,650
  • 19
  • 86
  • 115

2 Answers2

15

You probably want to use GCM in these situations.

Firebase works fine from a background service, but it leaves a socket open, so it's going to use quite a bit of power. This power usage is fine when a user is actively engaged with your app (the screen probably uses a lot more), but when it's running in the background, it's going to be hard on battery life.

In most cases, when your user isn't actively engaged, they're willing to accept slower response times, and push services like GCM are a better value in watts per user happiness.

Also, Firebase is working on adding triggers, as demonstrated in this video from Google Cloud Platform Live, that will make it a lot easier to integrate with push services like GCM in the future.

And I guess you could say James is a Firebase dev. He's one of the co-founders :)

mimming
  • 13,974
  • 3
  • 45
  • 74
  • 1
    "Also, Firebase is working on adding triggers ... " Link for this? I would like to see how Firebase currently works with GCM – Chad Bingham Dec 07 '14 at 18:04
  • The only link is the video I've already linked: https://www.youtube.com/embed/aCK_1sq6Dl0?start=15414 As for using GCM with Firebase now, there's no built in way to do it today. You will need to roll your own solution. I'd probably spin up a node.js worker to do the integration. – mimming Dec 09 '14 at 02:03
  • Hi, what if I want only to use firebase in background service till a message sent offline gets synced, else stop the service and use a broadcast receiver for push notifications.. Does this sound as battery efficient solution ? – Y M Feb 19 '15 at 07:25
  • @mango That's quite reasonable :) It's always a tradeoff. If you have a use case that requires realtime sync in the background, and it's worth the power consumption, it'll work great! – mimming Feb 23 '15 at 20:16
0

You could also try zapier.com which has a firebase + pushover integration to send gcm. but it will require some spending.for free you will have to develop this your self on your custom server, using firebase queue.

srinivas
  • 4,778
  • 2
  • 32
  • 43