Android Question fm_MessageArrived is not raised if an app is in background

An Schi

Well-Known Member
Licensed User
Do you send the push from firebase console or via http request of a b4j/a app.
The console is known to cause such issues and it is recomnended to use b4j.
 
Upvote 0

b4auser1

Well-Known Member
Licensed User
Longtime User
When I sent message programmatically app fm_MessageArrived was raised in background.

I have found the explanation why fm_MessageArrived is NOT raised in background when it is initated from Firebase console.
Firebase console sends always Display message (more details below).

https://stackoverflow.com/questions...tification-when-app-in-background-in-firebase

There are two types of messages in FCM (Firebase Cloud Messaging):
Display Messages: These messages trigger the onMessageReceived() callback only when your app is in foreground
Data Messages: Theses messages trigger the onMessageReceived() callback even if your app is in foreground/background/killed
Firebase team have not developed a UI to send data-messages to your devices, yet.


1. Why is this happening?

There are two types of messages in FCM (Firebase Cloud Messaging):

Display Messages: These messages trigger the onMessageReceived() callback only when your app is in foreground
Data Messages: Theses messages trigger the onMessageReceived() callback even if your app is in foreground/background/killed

NOTE: Be sure you're not adding JSON key notification

Display Messages
B4X:
    "notification": {
        "title" : "title text",
        "body" : "body text"
     },

Data Messages
B4X:
    "data": {
        "my_custom_key" : "my_custom_value",
        "other_key" : true
     },
 
Upvote 0
Top