FCM push notification is not working when the app in foreground

We have integrated chat in our product for Android app & Web Portal. If we send the message from portal we need display the push notification on the Android app.

The push notification is getting displayed when application is killed or background/ not visible (i.e. by pressing device home button).

But the push notification is not getting received when the app in foreground/ visible. The below mentioned method which is overridden by extending the com.google.firebase.messaging.FirebaseMessagingService.class

public void onMessageReceived(@NotNull RemoteMessage remoteMessage) {

but it is not getting called, When the android application is in foreground/visible.

connected state, you can receive a message through the channel event handler.

But if you want to get a push even when you are online? then you can enable always push in Sendbird dashboard(settings → chat → notifications → Push notifications for multi-device users → check(Send to devices both offline and online)

and add below code in
class MyFirebaseMessagingService extends SendBirdPushHandler {
protected boolean alwaysReceiveMessage() {
return true;

Thanks for the update