dhana
dhana

Reputation: 887

Prompt not working second time trying to add web app in Home Screen

Trying adding a web app in home screen in chrome latest browser, its working properly first time accessing but not working second time that mean not prompting the message:

Below is my code:

  1. created valid manifest json

  2. include manifest file in index.html

  3. and created service-worker.js

    self.addEventListener('fetch', function(event) {
          event.respondWith(
            caches.match(event.request).then(function(response) {
              if (response) {
                return response;
              }          
              return fetch(event.request).then(function(response) {
                return response;
              }).catch(function(error) {
                throw error;
              });
            })
          );
        });
    
  4. register service worker in html page

    if ('serviceWorker' in navigator) {
        console.log("Will the service worker register?");
        navigator.serviceWorker.register('service-worker.js')
          .then(function(reg){
            console.log("Yes, it did.");
          }).catch(function(err) {
            console.log("No it didn't. This happened: ", err)
          });
      }
    

Scenario:

  1. first time i hit the web page, its showing add screen prompt

  2. added in home screen

  3. uninstall the home screen page

  4. i tried hit the web page again, its not showing add screen prompt

Upvotes: 1

Views: 749

Answers (1)

oninross
oninross

Reputation: 999

The icon on your home screen is just a shortcut to a chrome browser with added flavours (full screen, splash screen, orientation, etc). So technically you just deleted the shortcut and not the app.

If you hit the kebab icon > info icon > Site Settings, you will be able to see that chrome has still saved it in the device. The only way to really uninstall/delete it is by clicking on that Clear & Reset button which would make chrome think that the site is being visited the first time.

I think "issue" would be a nice feature for the chrome team to implement in the browser. By "uninstalling" the PWA would clear and reset it as well.

Upvotes: 2

Related Questions