Background behavior for iOS Web App (so app doesn't restart)
Asked Answered
L

3

3

I'm trying to build a mobile web app and am intrigued by the "apple-mobile-web-app-capable" option, making the app feel a lot more native.

The issue I'm having is that it's an app that lets a user browse through a bunch of content, some of which opens a new browser window outside the web app (on purpose). The problem is, when a user goes back to the web app, it re-launches and starts them from the home page.

Has anyone found a way to avoid this complete reloading process?

Lissner answered 27/4, 2011 at 21:11 Comment(1)
Maybe a different solution that what you want, but you could implement tabbed browsing in your app, so you can have multiple links open without leaving and having to "restart" the app.Adelaadelaida
E
9

ive got it working like this:

if(window.navigator.standalone === true) {
    var lastpage = localStorage.getItem('exitsatus');
    if (lastpage==null){
        lastpage = "index.html";
    }
    if(document.referrer.length > 0 && document.referrer.indexOf("mysite.com") != -1){
        var lastpageupdate = window.location;
        localStorage.setItem('exitsatus',lastpageupdate);      
    } else {
        window.location = lastpage;
    }
}
Elihu answered 19/12, 2011 at 17:46 Comment(1)
Awesome work around. This got my creative juices flowing. Now I've got to think of a way to keep the server session alive.Spock
I
3

There is, but it's a bit of a hack and requires some JavaScript.

What you want to do is at the end of each page load, save the current path in offline key-value storage. In your head, see if there's an entry for the URL and if so, load it up. What you want to ensure is that internal links disable this key so that you don't just jump to a link and then back again.

Inenarrable answered 9/8, 2011 at 4:3 Comment(0)
L
-1

SO from what I gathered from other people outside SO, this just isn't possible.

Lissner answered 20/5, 2011 at 0:58 Comment(1)
localStorage is available to all HTML5 websites, even on desktopBradway

© 2022 - 2024 — McMap. All rights reserved.