Push Notification - txgz999/Mobile GitHub Wiki

Push Notification

Platform Notification System (PNS) and push handle

Push token (device token) - is a unique key for the app-device combination which is issued by the Apple or Google push notification gateways. It allows gateways and push notification providers to route messages and ensure the notification is delivered only to the unique app-device combination for which it is intended.

FCM is able to wake a device because the message is actually received by software components that come with Play services, which operates with elevated privileges. Play services can choose to wake the device and deliver the message to the target app.

The FCM software in Play services keeps a persistent socket connection open to its backend under normal circumstances. If it gets connection is dropped, it has logic to reestablish the connection without taxing the battery too much.

newer versions of Android allows a JobScheduler to check repeatedly for push messages from the Firebase server and if there is one, the device notifies the corresponding application and the application then generates the push notification.

How to keep apps running in the Background?

https://support.google.com/pixelphone/thread/6068458?hl=en

You can allow a certain app to run in the background by going to Settings > Apps & notifications > Advanced > Special app access > Battery optimization. This will initially show you the apps which are Not Optimized - that is, the ones that can run in the background even while the phone is sleeping. Tap the blue bar at the top of the screen and switch the view to All apps, then scroll down to the app you'd like to exclude (Fitbit, in this case), tap it, set it to Don't optimize, and then tap Done.