Web App Manifest: "start_url" doesn't work for Safari
Asked Answered
C

2

9

The "start_url" works for Android browsers, but for iPhone, Safari always uses current page's URL and ignores the "start_url".

For example, the current page is https://test.com/index.html, on manifest the "start_url" is set to be "start_url": "index.html?flag=1", but when the page is added to home screen on Safari, it still uses https://test.com/index.html, without the parameter.

Is there a way to apply a different URL as the start up URL for Safari?

Casein answered 21/2, 2017 at 22:31 Comment(2)
you can try this library github.com/GoogleChrome/pwacompatStonybroke
@jeremycastelli, thanks, the library does its jobHalfassed
W
2

A hacky solution I've implemented here is to silently change the URL on the page you prompt the user to install the PWA with: history.pushState({}, "", "/"); (see: https://mcmap.net/q/321180/-silently-update-url-without-triggering-route-in-vue-router)

This will update the URL but won't cause the page to reload or refresh the DOM, so you can see the page you're on as normal, but when the user goes to install the PWA (Add to home screen) it'll save the root URL, so that's what they'll see when they open the PWA.

Downsides here include:

  • the URL in the address bar will update (not a big deal on mobile)
  • if the user presses the back button they'll go "back" to the page you triggered the history.pushState() on, so they'll need to press back twice to actually go back
  • if the user refreshes the page they'll see the homepage

In my use case this is good enough, there might be extra solutions to handle these issues that could be applied on top of this solution to improve UX.

Woodcock answered 11/1, 2022 at 14:11 Comment(0)
G
-1

try this url format

"start_url": "./index.html?flag=1"

Garcia answered 10/5, 2020 at 12:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.