1

Lets say your server completes a process, a timer or something, and wants to call back to the application to update its state, regardless of whether or not the app is in the background/closed. What's the best way to handle this, FCM? And will that ensure the app always wakes?

Josh
  • 386
  • 5
  • 14
  • What do you mean with 'wake an application'? If you want to display a notification then you can look into a cloud messaging system such as FCM – Zun Sep 26 '18 at 07:41
  • Meaning to update some information about the state of the application while it's not active. This could be used so widgets update, etc. That way all the service calls updating a local cache or something don't have to wait for the next cold start. – Josh Sep 26 '18 at 07:48
  • Might not be the route you looking for and apologise in advance. I would implement a service running in the background and have a timer handler to deal with the update? I haven't seen a server which triggers functions in the application but I am looking forward to more input. – Nero Sep 26 '18 at 08:36
  • Definitely makes sense to have a periodic updater like that. At this point, I'm thinking that you can use FCM to notify the app to process/sync data as well, so you don't have to wait for the periodic updates.. I have no idea how to do it but that's another story. – Josh Sep 26 '18 at 09:06

1 Answers1

0

Yes, it is good case for FCM. Just send message from server and do what you want in FCM listener in app.

There are two types of messages in FCM: display messages and data messages. Display messages trigger the onMessageReceived only when app in foreground, data messages is what you want - trigger callback even if app killed.

There is answer with details how exactly do what you want.