OiO.lk Blog Android FirebaseMessagingService on Android does not work after application is removed from background
Android

FirebaseMessagingService on Android does not work after application is removed from background


I have this Notification Service:

@AndroidEntryPoint
class MessagingService : FirebaseMessagingService() {

    override fun onNewToken(token: String) {
        super.onNewToken(token)
    }

    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
        handleMessage(remoteMessage)}

I am using it to retrieve data messages from the Firebase, which are usually chat messages. Service properly works when app is in the foreground. If the app is dismissed from the recents tray, the Service also gets destroyed parallely.

I have even migrated to oauth API to push the new notifications but the result is same. Can anyone explain this behaviour of the service? How can I prevent it from being destroyed since I want to listen for the FCM notifications all the time. Thanks in Advance!



You need to sign in to view this answers

Exit mobile version