Is it possible to hide a notification which I receive from firebase through my api. Currently I am accessing the notification iny my MyFirebaseMessagingService like this:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent intent = new Intent(INTENT_FILTER);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
if (remoteMessage.getNotification().getBody() != null) {
setClientId(remoteMessage);
}
}
private void setClientId(RemoteMessage remoteMessage) {
RemoteMessage.Notification notification = remoteMessage.getNotification();
if (notification.getBody().equals("client_id")) {
putClientIdToSharedPrefs((notification.getTitle()));
}
}
I do not want to Show the message to the user in the Status bar, I just to receive the message and save it.
Yes. If you send from your API a notification object (which you probably do), the notification will be handled by the system.
So instead of sending:
"notification":{
"title": "New Notification!",
"body": "Test"
},
You can send:
"data":{
"title": "New Notification!",
"body": "Test"
},
That way, You will need to create the notification yourself if you want to show it to the user, but you will be able to catch the data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With