I want to start a background service when I received a special type of message. For this I am doing the following
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if(remoteMessage.getData().get("message").equals("something"){
//start service
}
}
}
My problem is, it only works when app is foreground , but when the app is in background onMessageReceived
doesn't trigger. Rather than it just show a notification .
What I want is to disable notification when app is in background , rather start a service.
I have looked other answers is SO, some of them suggest to accomplish this I need to send data-message
. And I am sending data message from firebase console, but it is not working.