Android Question FirebaseNotifications - Peculiar Behaviour?

Haris Hafeez

Active Member
Licensed User
Longtime User
I am using Firebase for push notifications. However, I have noted that when a message is pushed and my app is open (in the foreground), the FirebaseMessaging service's fm_MessageArrived is triggered and it works as expected.

However, quite oddly, this method does not seem to be triggered when my app is in the background (no activity visible). I have tested this in debug by setting a breakpoint in the service and in release by adding log statements. This method is not called BUT I can see a notification is indeed created and displayed in the notifications bar. Because of the fm_MessageArrived event not being raised, I cannot add the relevant information to the app (i update a process global in Main in this method).

How do I understand this behaviour? My device is Nexus 5X running 7.1.1.

Thanks for your help in advance.
 

Haris Hafeez

Active Member
Licensed User
Longtime User
I tested with both - with firebase console and then with a b4j app. And yes, I have tested it in release. Will do another run and see.
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
this method does not seem to be triggered when my app is in the background

On my Huawei P8 (P9 and 10 will be the same for sure) there is a energy saving option which stopps ALL unknown apps when the screen turns off. Only known apps like Facebook are set to "keep on running" by default (WhatsApp wasn't in this whitelist in the first versions of 6.x. After many complains Huawei pushed an update. Even my Google calendar wasn't updating).

Testing my app using FCM lead me to the same plcae like you. Please check this on your phone. Android 7 may have even more strict options (like "may throw notifications" or similar). Check that, too.
 
Upvote 0

Haris Hafeez

Active Member
Licensed User
Longtime User
This issue was because I was using the Firebase console. Sending from a B4J app doesn't cause this. Very odd. Though I have other issues, which I will start another thread. Thanks all.
 
Upvote 0
Top