# FCM push notification is not working when the app in foreground

**URL:** <https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969>\
**Category:** Android\
**Tags:** chatsdk, push-notification\
**Created:** [February 18, 2022, 5:24am UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969 "2022-02-18T05:24:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Development\_Account](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/development_account/32/1584_2.png) [@Development\_Account](https://community.sendbird.com/u/Development_Account)\
**Post date:** [February 18, 2022, 5:24am UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/1 "2022-02-18T05:24:22Z")

</div>

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`

```auto
@Override
public void onMessageReceived(@NotNull RemoteMessage remoteMessage) {
}

```

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

---

<div class="post-metadata">

**Author:** ![Yongjun\_Choi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/yongjun_choi/32/36_2.png) [@Yongjun\_Choi](https://community.sendbird.com/u/Yongjun_Choi)\
**Post date:** [February 18, 2022, 7:59am UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/2 "2022-02-18T07:59:28Z")

</div>

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

> **[Event handler | Chat Android SDK | Sendbird Docs](https://sendbird.com/docs/chat/v3/android/guides/event-handler#4-list-of-group-channel-events)**
>
> Learn about the functionalities of the 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 {  
@Override  
protected boolean alwaysReceiveMessage() {  
return true;  
}  
}

---

<div class="post-metadata">

**Author:** ![Development\_Account](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/development_account/32/1584_2.png) [@Development\_Account](https://community.sendbird.com/u/Development_Account)\
**Post date:** [March 17, 2022, 4:37am UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/3 "2022-03-17T04:37:37Z")

</div>

Thanks for the update

---

<div class="post-metadata">

**Author:** ![Ezzy\_Wachira](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/ezzy_wachira/32/4319_2.png) [@Ezzy\_Wachira](https://community.sendbird.com/u/Ezzy_Wachira)\
**Post date:** [July 25, 2023, 5:20pm UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/4 "2023-07-25T17:20:12Z")

</div>

What if someone is using their own Firebase Messaging Service that extends FirebaseMessagingService and not SendBirdPushHandler?

---

<div class="post-metadata">

**Author:** ![rahul](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rahul](https://community.sendbird.com/u/rahul)\
**Post date:** [July 27, 2023, 8:51am UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/5 "2023-07-27T08:51:10Z")

</div>

Hello @Ezzy_Wachira ,

Could you please elaborate what is the issue you are facing here?

---

<div class="post-metadata">

**Author:** ![Ezzy\_Wachira](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/ezzy_wachira/32/4319_2.png) [@Ezzy\_Wachira](https://community.sendbird.com/u/Ezzy_Wachira)\
**Post date:** [July 28, 2023, 5:18am UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/6 "2023-07-28T05:18:04Z")

</div>

The issue is that when I’m using my own Firebase Service instead of SendbirdPushHandler, I’m not able to set the property for always receive message which is an override function in SendbirdPushHandler to make sure I always receive push notifications for chats after updating chat settings to multidevice on the dashboard. Right now I only receive push notifications only when the app is closed or in the background since I was informed that when app is open, Sendbird ignores the push notification for chat so I do not receive push paypoad in my onMessageReceived of my firebase service class.

---

<div class="post-metadata">

**Author:** ![rahul](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rahul](https://community.sendbird.com/u/rahul)\
**Post date:** [July 28, 2023, 12:36pm UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/7 "2023-07-28T12:36:37Z")

</div>

Hello @Ezzy_Wachira ,

Could you please share me your app ID.  
Maybe the foreground notifications is disabled and I can try to enable it from our end so that you can receive the notifications when the app is open,

---

<div class="post-metadata">

**Author:** ![Ezzy\_Wachira](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/ezzy_wachira/32/4319_2.png) [@Ezzy\_Wachira](https://community.sendbird.com/u/Ezzy_Wachira)\
**Post date:** [July 29, 2023, 1:02pm UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/8 "2023-07-29T13:02:12Z")

</div>

Where can I send it since it’s more secret

---

<div class="post-metadata">

**Author:** ![Ezzy\_Wachira](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/ezzy_wachira/32/4319_2.png) [@Ezzy\_Wachira](https://community.sendbird.com/u/Ezzy_Wachira)\
**Post date:** [July 31, 2023, 11:09am UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/9 "2023-07-31T11:09:16Z")

</div>

Hi @rahul , Please let me know where to send you the APP\_ID since it’s confidential

---

<div class="post-metadata">

**Author:** ![rahul](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rahul](https://community.sendbird.com/u/rahul)\
**Post date:** [July 31, 2023, 11:26am UTC](https://community.sendbird.com/t/fcm-push-notification-is-not-working-when-the-app-in-foreground/3969/10 "2023-07-31T11:26:44Z")

</div>

I have DM’d you. Please share your app id there.
