问题
My site has several subsections. When a user adds the site to their homescreen, I'd like to make sure that the home screen icon launches them into the subsection they were on when they added to homescreen.
I can register a different manifest for each subsection, but this doesn't work for single page apps where there's no page reload. I'm considering storing the subsection in a cookie and then redirecting from a generic start URL based on that cookie.
Is there a better way to do this?
回答1:
If you remove the start_url
from the manifest.json file then it will default to the page user was browsing while adding pwa app to homescreen.
ref : https://developers.google.com/web/tools/lighthouse/audits/manifest-contains-start_url
回答2:
Have you tried changing the web app manifest url when the user navigates between different subsections?
document.querySelector('link[rel=manifest]').href = '/example-manifest.json';
回答3:
One solution is for each page do you have a separated manifest with attribute start_url specific to each page.
来源:https://stackoverflow.com/questions/39495573/set-start-url-in-web-app-manifest-based-on-the-url-that-was-added-to-homescreen