Android Tutorial FCM message workflow explained by Google

See here: https://firebase.googleblog.com/2018/09/handle-fcm-messages-on-android.html?linkId=57036840

There are 3 types of messages you can send combined with your app's state (fore- or background). Android FCM services behave different depending on the message type:

1.JPG


1. Notifcation only

As the name says it's just a notification (see the table above about how Android handles it). Android will throw a notification automatically when you app is in the background.

2. Data only

Good choice as you are free to send what you want (event lists/maps). If you need to throw an notification you need to do it on your own. However you service is started always which is nice.

3. Both (Notification AND Data)

See the table under "Both". When the user clicks on the notification the activity is started and you get the data via extras (intent)

I prefer to use data only messages as they are clear. The FCM service is always started automatically and you have to throw notifications on your own. Additonally you are free to fetch data or do any other stuff. Good for triggering your app if you own an server. Here you can send messages to "wake up your app" to do some stuff. No need for "StartServiceAt" or so.

Maximum load is 4KB which is enough to send a lot of data (or if it gets bigger just a "ping" to fetch the data from the server). Make sure your device let's your app run in the background (energy saving mode). Otherwise it does not receive any messages as it is fully stopped.
 
Top