13

Manifest., I want to modify the start_url of the json file after the page is loaded. This is because our app's start_url is different for each user. Because the parameters are different for each user, we need to load start_url dynamically I do not know how to fix it dynamically.

Is there any way to do this? Could it be possible when ServiceWorker is installed?

Blueming
  • 161
  • 1
  • 8
  • 1
    See http://stackoverflow.com/questions/41162262/ – Jeff Posnick Dec 15 '16 at 16:56
  • 1
    Right now that's the best answer I found. When I finish working on it I'll let you know: https://medium.com/@alshakero/how-to-setup-your-web-app-manifest-dynamically-using-javascript-f7fbee899a61 – gtamborero Nov 25 '18 at 21:45
  • Did you manage to find a solution for this? I've seen https://medium.com/@alshakero/how-to-setup-your-web-app-manifest-dynamically-using-javascript-f7fbee899a61 and it seems a bit dirty but maybe it is the only solution. – Royalsmed Mar 27 '19 at 21:22

2 Answers2

2

I solved a similar problem by using a url for a php file instead of a json file.

<link rel="manifest" href="/manifest.php?start_url=val">

The php file returns a json and when generating the page my server populates the url parameters dynamically. Everything working perfectly...

Johny
  • 501
  • 5
  • 16
  • 1
    Why is everyone giving answers involving PHP when the original question doesn't even mention PHP? – Michael Mar 06 '21 at 20:05
1

Suppose you have 3 categories. Make three .json files with respective scopes. Let's say japanese.json, black.json, voyeur.json

    $currentpage =$_SERVER['REQUEST_URI'];
    if ($currentpage == "/japanese") {
    $this->output('<link rel="manifest" href="/japanese.json">');}
    if ($currentpage == "/black") {
    $this->output('<link rel="manifest" href="/black.json">');}
    if ($currentpage == "/voyeur") {
    $this->output('<link rel="manifest" href="/voyeur.json">');}

You can also modify if you have a bunch of categories or the url structures are more complex.

Dr. Ted
  • 11
  • 2
  • First, the question asked for a different manifest PER USER. This would definitely be more than 3. Second, what is that, PHP? I didn't see anything about server side code in the question. – Michael Mar 06 '21 at 20:05