0

Hello I have an App for tracking a queue, so when a queue is called, it will send a notification from FCM to any other user in that queue. My question is, if the system kill my apps when running in the background (I read that android will kill background app periodically), will I be able to receive that notification? And if its not, then is there any solution to keep my app from being killed by the system? Thank you.

Ananda Pramono
  • 899
  • 1
  • 6
  • 18
  • Probably https://stackoverflow.com/a/53960344/529282 – Martheen Oct 11 '21 at 02:17
  • yes, you will receive the notification when app is killed. If you are using fcm token of firebase. You have to configure the FirebaseMessaging when app is in foreground, background or open after when terminated. For more info this is documentation of the firebase Messaging package. https://firebase.flutter.dev/docs/messaging/usage – Shahryar Rafique Oct 11 '21 at 02:42
  • @ShahryarRafique I see, but what if an app get killed by Battery Optimization? I'm afraid because of that, the notification will not received – Ananda Pramono Oct 11 '21 at 05:06

1 Answers1

1

Yes, you'll get the message. The actual message is sent over the network from Google's servers to a process on the device that is not subject to being killed (its part of Android). That process will restart your application by calling the approprate BroadcastReceiver when a message comes in. Please note that if the message is not high priority it will be subject to Doze mode rules. As long as your device is not turned off/loses network connectivity it will be received.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Hello thanks for your answer, so even if the App get killed by system (some phone with Battery Manager will kill the app in background for battery optimization) the notification still received? Because I dont think I can ask the user to turn off that battery optimization. Thank you – Ananda Pramono Oct 11 '21 at 02:52
  • Yes, it is. Because with FCM and other push messaging systems, its a separate process that's whitelisted from the power management rules that actually owns the socket listening for messages. And that process can wake up your app. – Gabe Sechan Oct 11 '21 at 05:32
  • I see, thank you very much – Ananda Pramono Oct 11 '21 at 05:39