As my web app will be used on iPads , I want to be able to detect that the connection to the App from the browser is lost.
It uses a Sqlite connection also.
On a desktop all works fine, but on an iPad, when I wait too long or turn off the screen and turn it on again,
the App is still visible in the iPad’s browser, but is no longer responding.
Instead, I would prefer it to either quit or display a message to the user that the connection was lost.
Any ideas on how to do this?
Have you looked at Session.timeout & the TimedOut Event?
It’s an interesting problem for sure. The main issue is that the app on the server gave up somewhere along the way, but mobile safari didn’t get the event because it was minimized or sleeping or something. When the iPad wakes, it tries to connect with your app again, but its “session” no longer exists.
A feature request is probably in order, if one doesn’t already exist.
no events are detected, Greg’s explanation makes sense. Hopefully something can be done about it, will see if I can find any feature request and if not, will create one (if I can). It’s most annoying when users switch Apps on an iPad, then come back and find a non-responsive App.
I have added a timer (like HeartBeat timer) on each web page that will increment a session variable by 1 every 7 seconds (this amount of time depends on my specific app), let’s say the variabile is called IamAlive.
Then I have added a thread (VerifyHeartBeats) that will run every 30 seconds (app specific timing) and for each session will check the IamAlive value. If the value is zero then will quit that session (detecting a closed or iPad-sleeping safari), otherwise it will zeroes the IamAlive variable. When changing web page, you must remember to disable the heartbeat timer on the page you are leaving and enable the one in the page that is currently showing. A little bit tricky but it works.
On an iPad, if Safari is hidden or the iPad is closed by the cover, timers will not run.