I am working on a little script that warns the user that his session is about to time out and his/her changes might not get saved.
On any browser, that works pretty well and I implemented a solution that just uses setTimeout to trigger a dialog box after a certain amount of time (unless the user takes certain actions in between).
On iOS Safari, however, this approach doesn’t work, as the setTimeout gets “halted” while the user navigates to another app on his/her phone. Once the user opens Safari again and comes back to the page, the timer continues where it left off, rather than looking at the total time that expired.
Any suggestions on how to approach a session timeout warning that doesn’t break on the iPhone?
Disclaimer: Handle case where user returns and session has ended.