meteorify
meteorify copied to clipboard
iOS app crash
If you leave the app in background some time, when back to be active the app crashes and restarts.
@gabdsg Meteor works using socket connections. When you put the app in background for quite sometime, the socket connection breaks.
Meteorify currently checks after a default interval for 60 seconds, and reconnects if the connection is broken.
You can reduce that interval down to 30 seconds or whatver suits your requirements by specifying the heartbeatInterval
property during the connection.
Meteor.connect("ws://example.com/websocket",heartbeatInterval: const Duration(seconds: 30));
Let me know if that solves your issue.
I tried changing the heartbeatInterval
with no luck
I tried changing the
heartbeatInterval
with no luck
Did you use a connection listener along with the heartbeatInterval
?
Please refer to the connectionListener in the documentation.
With reduced heartbeatInterval
, you'll get notified of the connection changes in the connection listener more frequently so there by when you get a ConnectionStatus.DISCONNECTED
status, you can connect back or display a message to the user accordingly.
This only happens in the iOS release version, not in debugging.
I have the heartbeatInterval
in 15 seconds.
I tried to disconnect meteor when the app goes into background and reconnect when it returns to the foreground, but it doesn't work all the time...
Hi @gabdsg , just wanted to check if this issue was resolved?
No... I have to disconnect it when it goes into the background
@gabdsg Is it possible to share a snippet of the code where you're handling the network connectivity with Meteor?
I have the Meteor.connect before runApp then i have this
Timer statusChangeTimer; void didChangeAppLifecycleState(AppLifecycleState state) { appState = state; if (state == AppLifecycleState.paused) { statusChangeTimer = Timer(const Duration(seconds: 15), () { Meteor.disconnect(); statusChangeTimer.cancel(); statusChangeTimer = null; }); } else if (state == AppLifecycleState.resumed) { statusChangeTimer?.cancel(); Meteor.reconnect(); } }
Is there any specific reason why you're using Meteor.connect
before the runApp()
?
Not really, why?
Not sure about how you're handling the state. However, have you tried listening to connection updates?