Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I dynamically modify start_url in the manifest.json file?

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?

like image 254
Blueming Avatar asked Dec 01 '16 00:12

Blueming


People also ask

How do I edit a manifest JSON file?

Editing a manifestOpen the script project in the Apps Script editor. At the left, click Project Settings settings. Select the Show "appsscript. json" manifest file in editor checkbox.

What is start_url in manifest JSON?

The start_url member is a string that represents the start URL of the web application — the preferred URL that should be loaded when the user launches the web application (e.g., when the user taps on the web application's icon from a device's application menu or homescreen).

What should be included in manifest JSON?

Using manifest. json , you specify basic metadata about your extension such as the name and version, and can also specify aspects of your extension's functionality (such as background scripts, content scripts, and browser actions).

Is manifest JSON necessary?

json is a simple JSON file in your website that tells the browser about your website on user's mobile device or desktop. Having a manifest is required by Chrome to show the Add to Home Screen prompt.


2 Answers

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...

like image 121
Johny Avatar answered Oct 22 '22 19:10

Johny


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.

like image 23
Dr. Ted Avatar answered Oct 22 '22 18:10

Dr. Ted