Back

Realtime stops working when phone screen is off

  • 0
  • General
  • Web
  • Realtime
kathelia.dokgu
29 Aug, 2023, 02:04

I'm not sure if this is an Appwrite thing or a NextJS thing. I have a NextJS web app where I have realtime functionality working as I expected. However, on mobile devices, if the user turns their screen off and comes back after receiving a realtime event that should add another element on the page, that element doesn't show up. They would have to refresh the page for it to appear.

TL;DR
The user is experiencing an issue with realtime functionality on their NextJS web app when using mobile devices. When the phone screen is turned off and then turned back on, a new element that should appear on the page from a realtime event does not show up. The user wonders if this issue exists in native iOS and Android apps. A suggestion is made to run a background job to periodically fetch or fetch once the app is running again, but it is mentioned that mobile apps have limited options due to OS restrictions. The user asks if there is a way to not miss any events and if they are stuck with having to refresh the page. The response
Drake
29 Aug, 2023, 03:14

Yes, this is expected. You'll need to detect when the user is back in the app and reconnect.

kathelia.dokgu
29 Aug, 2023, 03:34

What do you mean by reconnect? Like refresh the page?

Drake
29 Aug, 2023, 03:35

Subscribe again

kathelia.dokgu
29 Aug, 2023, 03:36

But that would only give me the new realtime events. The events that I missed when the screen was off won't be returned. No?

Drake
29 Aug, 2023, 03:37

Correct

kathelia.dokgu
29 Aug, 2023, 03:37

Is there a way to not miss any events? Or am I stuck with having to refresh the page so I get a fresh (complete) data?

Drake
29 Aug, 2023, 03:39

You can run a background job to periodically fetch or fetch once the app is running again.

You have very limited options on mobile because the OS has a lot of restrictions

kathelia.dokgu
29 Aug, 2023, 03:41

Hmmmm.. idk if I want to do that. I think I'll just refresh the page when the user comes back.

kathelia.dokgu
29 Aug, 2023, 03:42

I haven't done mobile dev in so long but do you know if this issue is also present on mobile applications (native iOS and Android apps)?

Drake
29 Aug, 2023, 04:00

Yes

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more