#Realtime turns off after 30 minutes
28 messages · Page 1 of 1 (latest)
I think the system OS kills the app to save battery
You can exclude the app from battery optimisation so it doesn't gets killed or implement a foreground service
How can I disable this or do I need to send a request to the server every 5 minutes in the background so that the system does not disable this to save battery?
thanks, I'll try
What's the app doing that needs that?
the application is a taxi service and a chat at the same time
So from what I understand it needs to send the location in the background, right?
Or the realtime connection is to get the messages?
yes to receive real time message
Well, in such case, I suggest a different approach
To get the messages in the background, you should use the appwrite messaging feature
When the user open the app, you fetch all the messages and stablish a realtime connection in order to get updates and the newest messages sent
I think it's better doing that because having a constant real-time connection will drain a lot of battery unnecessarily in the background
You can use messaging for realtime notification nothing else
Once you get the notification, you proceed to open the app, right?
I searched for a solution for a long time, but was able to solve the problem. Only realtime does not work after 30 minutes. and everything else works. For realtime to work again, you need to restart the application
Yes then the realtime connection gets connected again and everything will work in flow
That's the idea. I think the realtime should not be running in this case in the background after the app is closed
Because it will use more battery
And it's not needed at all
Yep
For example, the real-time feature works when the application is in the foreground. And let it not work when the application is in the background. And when the application moves to the foreground again, realtime no longer works. This happens if the application is in the background for exactly 30 minutes or more. Everything works for up to 30 minutes. but after 30 minutes the system does not kill the application. Only realtime doesn't work again. To get everything working again, you need to close and launch the application again.
I don't need real time work in the background. But I want the real time function to work when I switch to the foreground again. If after 30 minutes I switch to foreground, realtime stops working
You can connect again when the app comes in foreground
I wanted to resubscribe when the application switches to the foreground again, but in this case the subscription is duplicated and the console shows 2 connections when in fact only one client is connected
or do you need to close the subscription when switching to background?
Yes, if you want to disconnect, you have to close