简体   繁体   中英

iOS 13 [Add to Home Screen] and [Hide Toolbars]

In previous iOS (12 and before) or any Android phone, we are able to use the [Add to Home Screen] in Safari (or any browser in Android) and hide the toolbars of a PWA by using the following techniques:

  1. in Index.html:
<head>
    <meta name="viewport" content="viewport-fit=cover, width=device-width,initial-scale=1.0, maximum-scale=1.0, shrink-to-fit=no">
    <link rel="apple-touch-icon" href="/customicon.png"/>
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="application-name" content="BGBG01">
    <meta name="apple-mobile-web-app-title" content="BGBG01">
    <meta name="msapplication-starturl" content="/">
    <link rel="manifest" href="manifest.json">
</head>

  1. Create a file manifest.json in the root directory, with the following content:
{
  "name": "App Full Name",
  "short_name": "AppName",
  "lang": "zh-CN",
  "start_url": "/",
  "scope": "/",
  "display": "standalone"
}

However, since iOS 13, the above method does not work anymore, the toolbars persist and we need to click the aA on the left hand side of the Address Bar, then choose [Hide Tool Bar] EVERY TIME, in order to hide the toolbars of the PWA.

So how can we hide the toolbars?

Edit

Just want to emphasize that the following js code does not work as well:

<script>
  if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
    /* iOS hides Safari address bar */
    window.addEventListener("load",function() {
        setTimeout(function() {
            window.scrollTo(0, 1);
        }, 1000);
    });
  }
</script>

or

<body>
<button id="goFS">Go fullscreen</button>

<script>
  var goFS = document.getElementById("goFS");
  goFS.addEventListener("click", function() {
      document.body.requestFullscreen();
  }, false);
</script>

</body>

And the solution provided by this link is also not working:

https://codepen.io/akikoo/pen/xdaic

Can be smart and efficiently for your case this method ? Using this minimal webmanifest the menu bar disappear for you too?

{
  "name": "My Super App",
  "short_name": "My App",
  "display": "standalone",
  "scope": "/my-app-path/",
  "start_url": "/my-app-path/"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM