Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent web app restart on iPad task switch

I have a web app running on an iPad. It is running in full-screen mode. If I task switch to another app (by double-clicking the home button etc), then switch back to my web app, then my web app restarts.

Is there any way to prevent the web app from restarting when it receives the focus after an iPad task switch? Obviously I just want it to show itself in exactly the state it was in when it lost focus.

Thanks.

like image 683
Journeyman Avatar asked Jul 20 '11 08:07

Journeyman


People also ask

How do I turn off multitasking on my iPad?

First, Launch the “Settings” app. Navigate to General > Multitasking (this is called “Multitasking & Dock” on iOS 11 and 12). Find the Allow Multiple Apps, Persistent Video Overlay, and Gestures switches and tap each one to turn the features off.

What is the iPad app switcher?

Use the App SwitcherTo browse the open apps, swipe right, then tap the app or Split View workspace you want to use. You can view the Slide Over windows by swiping left, and switch between them by tapping them. See Switch between apps in Slide Over.


1 Answers

No, this is not possible.

The best way to act is to save a state into localStorage. If you're using eg. URL hash for tracking your state (eg. myApp.html/#loginScreen), one can store that info and then apply it on location.hash which would dispatch window.onhashchange.

In other words (codes are just example written on fly):

1 - store relevant information to localStorage:

localStorage.setItem("state", "loginScreen");

2 - retrieve value on start up and apply it to hash:

location.hash = (localStorage.getItem("state")) ? localStorage.getItem("state") : "";

3 - bind an event listener to onhashchange and proceed from there:

window.addEventListener("hashchange", function() {
    if (location.hash.length) {
        alert("Current state of UI is :"+ location.hash);
    }   
}, false);
like image 132
Samuli Hakoniemi Avatar answered Oct 06 '22 01:10

Samuli Hakoniemi