# onChannelChanged, onMessageReceived do not trigger when app in background or lockscreen

**URL:** <https://community.sendbird.com/t/onchannelchanged-onmessagereceived-do-not-trigger-when-app-in-background-or-lockscreen/7471>\
**Category:** JavaScript\
**Tags:** group-channel, chatsdk, react-native\
**Created:** [June 1, 2023, 3:39am UTC](https://community.sendbird.com/t/onchannelchanged-onmessagereceived-do-not-trigger-when-app-in-background-or-lockscreen/7471 "2023-06-01T03:39:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zdungx](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/zdungx/32/4018_2.png) [@zdungx](https://community.sendbird.com/u/zdungx)\
**Post date:** [June 1, 2023, 3:39am UTC](https://community.sendbird.com/t/onchannelchanged-onmessagereceived-do-not-trigger-when-app-in-background-or-lockscreen/7471/1 "2023-06-01T03:39:04Z")

</div>

When my phone lock the screen, I cannot receive any event handler new group channel added. (onChanelChanged or onMessageReceived )  
Do we have any solution to update list channel when app in background or lockscreen.

Device: iOS / android  
Platform: React native  
Language: typescript  
Sendbird package: “sendbird”: “3.1.9”

---

<div class="post-metadata">

**Author:** ![zdungx](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/zdungx/32/4018_2.png) [@zdungx](https://community.sendbird.com/u/zdungx)\
**Post date:** [June 1, 2023, 3:51am UTC](https://community.sendbird.com/t/onchannelchanged-onmessagereceived-do-not-trigger-when-app-in-background-or-lockscreen/7471/2 "2023-06-01T03:51:37Z")

</div>

@uday.bhaskar Could you help take a look?

---

<div class="post-metadata">

**Author:** ![Airen\_Kang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/airen_kang/32/1831_2.png) [@Airen\_Kang](https://community.sendbird.com/u/Airen_Kang)\
**Post date:** [June 2, 2023, 12:25pm UTC](https://community.sendbird.com/t/onchannelchanged-onmessagereceived-do-not-trigger-when-app-in-background-or-lockscreen/7471/3 "2023-06-02T12:25:05Z")

</div>

Hi @zdungx

React-Native operates in a JavaScript thread rather than a native one, so the JavaScript thread itself generally doesn’t run when the app moves to the background.

To notify the SDK when the app moves to the background, the `sdk.setBackgroundState` / `sdk.setForegroundState` API is provided. By using the mentioned API and collection, you can receive and handle events that occurred while the app was in the background when it returns to the foreground.

For more information, you can refer to the following documentation:

- Using Group Channel Collection: [Group channel collection | Chat JavaScript SDK | Sendbird Docs](https://sendbird.com/docs/chat/v4/javascript/local-caching/using-group-channel-collection/group-channel-collection#2-channel-events)
- Local Caching Overview: [Local caching | Chat JavaScript SDK | Sendbird Docs](https://sendbird.com/docs/chat/v4/javascript/local-caching/overview-local-caching#1-local-caching)

---

<div class="post-metadata">

**Author:** ![zdungx](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/zdungx/32/4018_2.png) [@zdungx](https://community.sendbird.com/u/zdungx)\
**Post date:** [June 7, 2023, 2:48pm UTC](https://community.sendbird.com/t/onchannelchanged-onmessagereceived-do-not-trigger-when-app-in-background-or-lockscreen/7471/4 "2023-06-07T14:48:08Z")

</div>

Hi @Airen_Kang

Thank you for your reply.

Could we receive these events when the app running in the background?  
Or these events will occur when the app resumes in the foreground from background mode?  
And is it work for android and ios?

anyway let me try it.
