Search code examples
cocoa-touchipadweb-applicationsios

Add window.navigator.standalone to UIWebView DOM


You know how a "webapp" can be installed via Mobile Safari by tapping the + button? And by launching this app via the homescreen your webapp knows that it was launched from the homescreen because window.navigator.standalone is set to 1...

Well..

I made an iOS app with a UIWebView that loads a web app. And now I'd like to add the window.navigator.standalone property to the dom of my webapp... is that possible?

Thanks


Solution

  • Inject some Javascript into the webview from the objective C to set the parameter manually

    [webView stringByEvaluatingJavaScriptFromString:@"window.navigator.standalone=1"];
    

    -Dx