Service-worker doesn't install only adds to home screen












0















I'm trying to install the pwa onto my mobile device. I only am able to add to home screen. Does anyone have any idea why this is happening?










share|improve this question



























    0















    I'm trying to install the pwa onto my mobile device. I only am able to add to home screen. Does anyone have any idea why this is happening?










    share|improve this question

























      0












      0








      0








      I'm trying to install the pwa onto my mobile device. I only am able to add to home screen. Does anyone have any idea why this is happening?










      share|improve this question














      I'm trying to install the pwa onto my mobile device. I only am able to add to home screen. Does anyone have any idea why this is happening?







      install service-worker progressive-web-apps






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 31 '18 at 8:36









      DasDas

      34




      34
























          1 Answer
          1






          active

          oldest

          votes


















          1














          To make your PWA installable you need to meet up the following requirments:




          • A web manifest,with the correct fields filled in.

          • The website to be served from a secure(HTTPS) domain.

          • An icon to represent the app on the device.

          • A service worker registered with a fetch eventhandler,to make the app work offline(this is only required by chrome for Android currently).


          You must include your manifest file in section of your index.html,like this



              <link rel="manifest" href="name.webmanifest">


          Your manifest should contain the following fields,most of which are self explanatory.



          {
          "background_color": "purple",
          "description": "Shows random fox pictures. Hey, at least it isn't cats.",
          "display": "fullscreen",
          "icons": [
          {
          "src": "icon/fox-icon.png",
          "sizes": "192x192",
          "type": "image/png"
          }
          ],
          "name": "Awesome fox pictures",
          "short_name": "Foxes",
          "start_url": "/pwa-examples/a2hs/index.html"
          }


          Now when the browser finds the manifest file with all requirements fulfilled,it will fire a beforeinstallprompt and accordingly you have to show the A2HS dialog.



          NOTE:




          • Different browsers have different criteria for installation, or to trigger the beforeinstallprompt event.

          • Starting in Chrome 68 on Android (Stable in July 2018), Chrome will no longer show the add to home screen banner. If the site meets the add to home screen criteria, Chrome will show the mini-infobar.


          For A2HS dialog:



          Add a button in your document,to allow user to do the installation



              <button class="add-button">Add to home screen</button>


          Provide some styling



          .add-button {
          position: absolute;
          top: 1px;
          left: 1px;
          }


          Now in the JS file where you register your service worker add the following code



          let deferredPrompt;

          //reference to your install button
          const addBtn = document.querySelector('.add-button');

          //We hide the button initially because the PWA will not be available for
          //install until it follows the A2HS criteria.
          addBtn.style.display = 'none';

          window.addEventListener('beforeinstallprompt', (e) => {
          // Prevent Chrome 67 and earlier from automatically showing the prompt
          e.preventDefault();
          // Stash the event so it can be triggered later.
          deferredPrompt = e;
          // Update UI to notify the user they can add to home screen
          addBtn.style.display = 'block';

          addBtn.addEventListener('click', (e) => {
          // hide our user interface that shows our A2HS button
          addBtn.style.display = 'none';
          // Show the prompt
          deferredPrompt.prompt();
          // Wait for the user to respond to the prompt
          deferredPrompt.userChoice.then((choiceResult) => {
          if (choiceResult.outcome === 'accepted') {
          console.log('User accepted the A2HS prompt');
          } else {
          console.log('User dismissed the A2HS prompt');
          }
          deferredPrompt = null;
          });
          });
          });





          share|improve this answer


























          • can you show me your how.js

            – Punit Jain
            Dec 31 '18 at 16:42











          • As of right now it is empty

            – Das
            Dec 31 '18 at 19:54











          • @Das can you make following changes as I have suggested in my answer and test accordingly to this link developers.google.com/web/fundamentals/app-install-banners/…

            – Punit Jain
            Jan 1 at 6:14











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53985274%2fservice-worker-doesnt-install-only-adds-to-home-screen%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          To make your PWA installable you need to meet up the following requirments:




          • A web manifest,with the correct fields filled in.

          • The website to be served from a secure(HTTPS) domain.

          • An icon to represent the app on the device.

          • A service worker registered with a fetch eventhandler,to make the app work offline(this is only required by chrome for Android currently).


          You must include your manifest file in section of your index.html,like this



              <link rel="manifest" href="name.webmanifest">


          Your manifest should contain the following fields,most of which are self explanatory.



          {
          "background_color": "purple",
          "description": "Shows random fox pictures. Hey, at least it isn't cats.",
          "display": "fullscreen",
          "icons": [
          {
          "src": "icon/fox-icon.png",
          "sizes": "192x192",
          "type": "image/png"
          }
          ],
          "name": "Awesome fox pictures",
          "short_name": "Foxes",
          "start_url": "/pwa-examples/a2hs/index.html"
          }


          Now when the browser finds the manifest file with all requirements fulfilled,it will fire a beforeinstallprompt and accordingly you have to show the A2HS dialog.



          NOTE:




          • Different browsers have different criteria for installation, or to trigger the beforeinstallprompt event.

          • Starting in Chrome 68 on Android (Stable in July 2018), Chrome will no longer show the add to home screen banner. If the site meets the add to home screen criteria, Chrome will show the mini-infobar.


          For A2HS dialog:



          Add a button in your document,to allow user to do the installation



              <button class="add-button">Add to home screen</button>


          Provide some styling



          .add-button {
          position: absolute;
          top: 1px;
          left: 1px;
          }


          Now in the JS file where you register your service worker add the following code



          let deferredPrompt;

          //reference to your install button
          const addBtn = document.querySelector('.add-button');

          //We hide the button initially because the PWA will not be available for
          //install until it follows the A2HS criteria.
          addBtn.style.display = 'none';

          window.addEventListener('beforeinstallprompt', (e) => {
          // Prevent Chrome 67 and earlier from automatically showing the prompt
          e.preventDefault();
          // Stash the event so it can be triggered later.
          deferredPrompt = e;
          // Update UI to notify the user they can add to home screen
          addBtn.style.display = 'block';

          addBtn.addEventListener('click', (e) => {
          // hide our user interface that shows our A2HS button
          addBtn.style.display = 'none';
          // Show the prompt
          deferredPrompt.prompt();
          // Wait for the user to respond to the prompt
          deferredPrompt.userChoice.then((choiceResult) => {
          if (choiceResult.outcome === 'accepted') {
          console.log('User accepted the A2HS prompt');
          } else {
          console.log('User dismissed the A2HS prompt');
          }
          deferredPrompt = null;
          });
          });
          });





          share|improve this answer


























          • can you show me your how.js

            – Punit Jain
            Dec 31 '18 at 16:42











          • As of right now it is empty

            – Das
            Dec 31 '18 at 19:54











          • @Das can you make following changes as I have suggested in my answer and test accordingly to this link developers.google.com/web/fundamentals/app-install-banners/…

            – Punit Jain
            Jan 1 at 6:14
















          1














          To make your PWA installable you need to meet up the following requirments:




          • A web manifest,with the correct fields filled in.

          • The website to be served from a secure(HTTPS) domain.

          • An icon to represent the app on the device.

          • A service worker registered with a fetch eventhandler,to make the app work offline(this is only required by chrome for Android currently).


          You must include your manifest file in section of your index.html,like this



              <link rel="manifest" href="name.webmanifest">


          Your manifest should contain the following fields,most of which are self explanatory.



          {
          "background_color": "purple",
          "description": "Shows random fox pictures. Hey, at least it isn't cats.",
          "display": "fullscreen",
          "icons": [
          {
          "src": "icon/fox-icon.png",
          "sizes": "192x192",
          "type": "image/png"
          }
          ],
          "name": "Awesome fox pictures",
          "short_name": "Foxes",
          "start_url": "/pwa-examples/a2hs/index.html"
          }


          Now when the browser finds the manifest file with all requirements fulfilled,it will fire a beforeinstallprompt and accordingly you have to show the A2HS dialog.



          NOTE:




          • Different browsers have different criteria for installation, or to trigger the beforeinstallprompt event.

          • Starting in Chrome 68 on Android (Stable in July 2018), Chrome will no longer show the add to home screen banner. If the site meets the add to home screen criteria, Chrome will show the mini-infobar.


          For A2HS dialog:



          Add a button in your document,to allow user to do the installation



              <button class="add-button">Add to home screen</button>


          Provide some styling



          .add-button {
          position: absolute;
          top: 1px;
          left: 1px;
          }


          Now in the JS file where you register your service worker add the following code



          let deferredPrompt;

          //reference to your install button
          const addBtn = document.querySelector('.add-button');

          //We hide the button initially because the PWA will not be available for
          //install until it follows the A2HS criteria.
          addBtn.style.display = 'none';

          window.addEventListener('beforeinstallprompt', (e) => {
          // Prevent Chrome 67 and earlier from automatically showing the prompt
          e.preventDefault();
          // Stash the event so it can be triggered later.
          deferredPrompt = e;
          // Update UI to notify the user they can add to home screen
          addBtn.style.display = 'block';

          addBtn.addEventListener('click', (e) => {
          // hide our user interface that shows our A2HS button
          addBtn.style.display = 'none';
          // Show the prompt
          deferredPrompt.prompt();
          // Wait for the user to respond to the prompt
          deferredPrompt.userChoice.then((choiceResult) => {
          if (choiceResult.outcome === 'accepted') {
          console.log('User accepted the A2HS prompt');
          } else {
          console.log('User dismissed the A2HS prompt');
          }
          deferredPrompt = null;
          });
          });
          });





          share|improve this answer


























          • can you show me your how.js

            – Punit Jain
            Dec 31 '18 at 16:42











          • As of right now it is empty

            – Das
            Dec 31 '18 at 19:54











          • @Das can you make following changes as I have suggested in my answer and test accordingly to this link developers.google.com/web/fundamentals/app-install-banners/…

            – Punit Jain
            Jan 1 at 6:14














          1












          1








          1







          To make your PWA installable you need to meet up the following requirments:




          • A web manifest,with the correct fields filled in.

          • The website to be served from a secure(HTTPS) domain.

          • An icon to represent the app on the device.

          • A service worker registered with a fetch eventhandler,to make the app work offline(this is only required by chrome for Android currently).


          You must include your manifest file in section of your index.html,like this



              <link rel="manifest" href="name.webmanifest">


          Your manifest should contain the following fields,most of which are self explanatory.



          {
          "background_color": "purple",
          "description": "Shows random fox pictures. Hey, at least it isn't cats.",
          "display": "fullscreen",
          "icons": [
          {
          "src": "icon/fox-icon.png",
          "sizes": "192x192",
          "type": "image/png"
          }
          ],
          "name": "Awesome fox pictures",
          "short_name": "Foxes",
          "start_url": "/pwa-examples/a2hs/index.html"
          }


          Now when the browser finds the manifest file with all requirements fulfilled,it will fire a beforeinstallprompt and accordingly you have to show the A2HS dialog.



          NOTE:




          • Different browsers have different criteria for installation, or to trigger the beforeinstallprompt event.

          • Starting in Chrome 68 on Android (Stable in July 2018), Chrome will no longer show the add to home screen banner. If the site meets the add to home screen criteria, Chrome will show the mini-infobar.


          For A2HS dialog:



          Add a button in your document,to allow user to do the installation



              <button class="add-button">Add to home screen</button>


          Provide some styling



          .add-button {
          position: absolute;
          top: 1px;
          left: 1px;
          }


          Now in the JS file where you register your service worker add the following code



          let deferredPrompt;

          //reference to your install button
          const addBtn = document.querySelector('.add-button');

          //We hide the button initially because the PWA will not be available for
          //install until it follows the A2HS criteria.
          addBtn.style.display = 'none';

          window.addEventListener('beforeinstallprompt', (e) => {
          // Prevent Chrome 67 and earlier from automatically showing the prompt
          e.preventDefault();
          // Stash the event so it can be triggered later.
          deferredPrompt = e;
          // Update UI to notify the user they can add to home screen
          addBtn.style.display = 'block';

          addBtn.addEventListener('click', (e) => {
          // hide our user interface that shows our A2HS button
          addBtn.style.display = 'none';
          // Show the prompt
          deferredPrompt.prompt();
          // Wait for the user to respond to the prompt
          deferredPrompt.userChoice.then((choiceResult) => {
          if (choiceResult.outcome === 'accepted') {
          console.log('User accepted the A2HS prompt');
          } else {
          console.log('User dismissed the A2HS prompt');
          }
          deferredPrompt = null;
          });
          });
          });





          share|improve this answer















          To make your PWA installable you need to meet up the following requirments:




          • A web manifest,with the correct fields filled in.

          • The website to be served from a secure(HTTPS) domain.

          • An icon to represent the app on the device.

          • A service worker registered with a fetch eventhandler,to make the app work offline(this is only required by chrome for Android currently).


          You must include your manifest file in section of your index.html,like this



              <link rel="manifest" href="name.webmanifest">


          Your manifest should contain the following fields,most of which are self explanatory.



          {
          "background_color": "purple",
          "description": "Shows random fox pictures. Hey, at least it isn't cats.",
          "display": "fullscreen",
          "icons": [
          {
          "src": "icon/fox-icon.png",
          "sizes": "192x192",
          "type": "image/png"
          }
          ],
          "name": "Awesome fox pictures",
          "short_name": "Foxes",
          "start_url": "/pwa-examples/a2hs/index.html"
          }


          Now when the browser finds the manifest file with all requirements fulfilled,it will fire a beforeinstallprompt and accordingly you have to show the A2HS dialog.



          NOTE:




          • Different browsers have different criteria for installation, or to trigger the beforeinstallprompt event.

          • Starting in Chrome 68 on Android (Stable in July 2018), Chrome will no longer show the add to home screen banner. If the site meets the add to home screen criteria, Chrome will show the mini-infobar.


          For A2HS dialog:



          Add a button in your document,to allow user to do the installation



              <button class="add-button">Add to home screen</button>


          Provide some styling



          .add-button {
          position: absolute;
          top: 1px;
          left: 1px;
          }


          Now in the JS file where you register your service worker add the following code



          let deferredPrompt;

          //reference to your install button
          const addBtn = document.querySelector('.add-button');

          //We hide the button initially because the PWA will not be available for
          //install until it follows the A2HS criteria.
          addBtn.style.display = 'none';

          window.addEventListener('beforeinstallprompt', (e) => {
          // Prevent Chrome 67 and earlier from automatically showing the prompt
          e.preventDefault();
          // Stash the event so it can be triggered later.
          deferredPrompt = e;
          // Update UI to notify the user they can add to home screen
          addBtn.style.display = 'block';

          addBtn.addEventListener('click', (e) => {
          // hide our user interface that shows our A2HS button
          addBtn.style.display = 'none';
          // Show the prompt
          deferredPrompt.prompt();
          // Wait for the user to respond to the prompt
          deferredPrompt.userChoice.then((choiceResult) => {
          if (choiceResult.outcome === 'accepted') {
          console.log('User accepted the A2HS prompt');
          } else {
          console.log('User dismissed the A2HS prompt');
          }
          deferredPrompt = null;
          });
          });
          });






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 1 at 6:11

























          answered Dec 31 '18 at 9:55









          Punit JainPunit Jain

          9318




          9318













          • can you show me your how.js

            – Punit Jain
            Dec 31 '18 at 16:42











          • As of right now it is empty

            – Das
            Dec 31 '18 at 19:54











          • @Das can you make following changes as I have suggested in my answer and test accordingly to this link developers.google.com/web/fundamentals/app-install-banners/…

            – Punit Jain
            Jan 1 at 6:14



















          • can you show me your how.js

            – Punit Jain
            Dec 31 '18 at 16:42











          • As of right now it is empty

            – Das
            Dec 31 '18 at 19:54











          • @Das can you make following changes as I have suggested in my answer and test accordingly to this link developers.google.com/web/fundamentals/app-install-banners/…

            – Punit Jain
            Jan 1 at 6:14

















          can you show me your how.js

          – Punit Jain
          Dec 31 '18 at 16:42





          can you show me your how.js

          – Punit Jain
          Dec 31 '18 at 16:42













          As of right now it is empty

          – Das
          Dec 31 '18 at 19:54





          As of right now it is empty

          – Das
          Dec 31 '18 at 19:54













          @Das can you make following changes as I have suggested in my answer and test accordingly to this link developers.google.com/web/fundamentals/app-install-banners/…

          – Punit Jain
          Jan 1 at 6:14





          @Das can you make following changes as I have suggested in my answer and test accordingly to this link developers.google.com/web/fundamentals/app-install-banners/…

          – Punit Jain
          Jan 1 at 6:14


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53985274%2fservice-worker-doesnt-install-only-adds-to-home-screen%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas