Reputation: 887
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:
created valid manifest json
include manifest file in index.html
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;
});
})
);
});
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:
first time i hit the web page, its showing add screen prompt
added in home screen
uninstall the home screen page
i tried hit the web page again, its not showing add screen prompt
Upvotes: 1
Views: 749
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