How to prevent webpage from closing on iPhone

My problem is that my web app is closed when Safari is inactive for 3 mins. How to extend the timeout period? I tried to put this in the Open event “Session.timeout = 600” but didn’t help.


Stick a WebTimer on the page, mode = 2 (multiple), period = 30000 (30 seconds). That will send an event to the server every 30 seconds and should keep your page alive.

That shouldn’t be necessary. The javascript framework should be pinging the server once per minute on its own. Please file a bug report with a sample project and exact specs of your system (where the app is being run and where your browser is), what version of Xojo you are using, etc. If this is really broken, we need to get it fixed asap.

FWIW, Session.Timeout is for telling your app when a user has actually stopped using your app for a period of time. Using the example you gave, after 10 minutes of inactivity, the Session.TimedOut event would have fired allowing you to log off the user if necessary.

I wrote a simple web app has a label and a web timer, the timer fires every second to update the label with current time. On iPhone, I open the web app in safari and then I pressed the home button to bring Safari inactive. Sometimes, I even receive phone call to force safari to become inactive for several minutes. After 3 minutes 14 seconds, when I bring up safari, the label stops updating.
I don’t think this is a bug. I think this is just a behavior of how the browser handles the page. I really want to know if anyone here has experience on how to handle this. Thank you.

The real project I am working has a few buttons and a canvas. User presses the button to draw something on the canvas. However, when the user answer phone call for more than 3 minutes and then re-activate safari, the drawing is still there but the button clicked events are no longer fired. What I am thinking is to keep the page alive or save the current state before the page close and redraw everything when the user hit reload. Any idea?


[quote=48359:@Philip Fu]What I am thinking is to keep the page alive or save the current state before the page close and redraw everything when the user hit reload. Any idea?


If Safari has it’s own way of effectively shutting down, sounds like the best bet.

That’s what you’d need to do. When you close safari to do something else, it stops sending messages to the server. After ~3 min, the app gives up and closes the session. This is true for any browser connection, desktop or mobile.

I rewrote some codes to save state on DB and set cookies to browser. When user reload the page it shows an option to restore the saved state or start over again. So far so good.

One more question, like I said earlier the page stay the same after the session is closed, is there a way to notify the user that the page has been disconnected from server? Usually people will keep pressing anything they see on the page and then file a complain to us if the page isn’t responding.

but to have a longer time of three minutes, how to act!