Android Question App swiped/killed: FCM listener

KMatle

Expert
Licensed User
Longtime User
My APP using FCM works as it should:

- if it's running, it receives notifications in the foreground
- if it's paused, Google does it's job and shows a notification whch can be clicked

If I "swipe" it away (= kill it), the app is gone and so the FCM service and listener. I defined the FCM service as sticky but it does not work (should be recreated). Any idea?
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I defined the FCM service as sticky but it does not work
You don't need to declare it as a sticky service.

FCM should work after you kill the app by swiping it from the recent apps list (which is not the same as killing it from the settings screen).
I've just verified it on Nexus 5X running Android 7.

It seems like on some versions of Android (might depend on the manufacturer) it doesn't behave correctly and the app is put in the stopped state. The same as killing from the setting screen. In this case the app will not receive anything until it is explicitly started by the user.
https://developer.android.com/about/versions/android-3.1.html#launchcontrols

The app will not be killed if there is a foreground service. However this is not the recommended way to implement push notifications.
 
Upvote 0

inakigarm

Well-Known Member
Licensed User
Longtime User
You don't need to declare it as a sticky service.

FCM should work after you kill the app by swiping it from the recent apps list (which is not the same as killing it from the settings screen).
I've just verified it on Nexus 5X running Android 7.
I can confirm that on my mobile phone (Android 6.0) the behaviour is as Erel states (swipe notifications doesn't stop for receiving FCM messages)
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Upvote 0

KMatle

Expert
Licensed User
Longtime User
FCM should work after you kill the app by swiping it from the recent apps list

Yes, you are (of course) correct. I just startet B4J and changed the code a bit. While testing (I did not update or even use my B4A app since yesterday) I then noticed several notifications (caused by my test). Works as designed.
 
Upvote 0
Top