Is there a way of telling whether my Web Application has been launched from a button on the user's iPhone home screen? I want to display a "add this WebApp to your home screen" prompt if the user has accessed the WebApp via safari by typing in a URL.
You can add shortcuts to the Home Screen, and optionally group them into folders. In the Shortcuts app on your iOS or iPadOS device, tap on a shortcut, then tap to open Details. Tap Add to Home Screen.
At the bottom of the Safari browser, find and tap on the share icon on the menu bar – it looks like a box with an up arrow. From the list of share options, choose Add to Home Screen. An app-looking icon will pre-populate. Give it a name that is recognizable to you.
window.navigator.standalone
True if you have launched from the Home Screen. False if in the Safari browser.
Documented here:
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html
It works with OS 2.1 and up.
In Safari, the scrollY
will start at a negative value if inside Safari, and at 0 if running as an application.
Likely the viewport will change as well (if it does, this is a more reliable method)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With