Kenji Kenji -4 years ago 69
Android Question

Findout when Firebase message recieved when app in background

I know that there is the same question with this title but unfortunately it is not answered right and it is accepted!!! here

I want to know how I can find out a FCM message received when app is in background to do some action on message received before clicking by user. but when app is in background

onMessageReceived
is not triggered!

I googled so much and could not find a good way.

Answer Source

As I've mentioned in the comments section, when sending a message with a notification message payload the Android System (Notification Tray) will handle the push notification when your app is in background.

You should use a data-only message payload, so that it will always be handled by onMessageReceived().

See the Handling Messages docs in Android for more details.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download