beforeinstallprompt not firing automatically
Reported by
brajmina...@gmail.com,
May 25 2018
|
||||
Issue descriptionChrome Version : 66.0.3359.181 OS Version: 6.1 (Windows 7, Windows Server 2008 R2) URLs (if applicable) : https://projectclean.herokuapp.com/ Other browsers tested: Add OK or FAIL after other browsers where you have tested this issue: Safari: OK Firefox: OK IE/Edge: OK cc dominickn@chromium.org What steps will reproduce the problem? 1. Open the website in android chrome. 2. The banner suggesting to add the app to homescreen doesn't appears 3. The 'beforeinstallprompt' doesn't fires automatically I went through the manual https://developers.google.com/web/fundamentals/engage-and-retain/app-install-banners/#testing-the-app-install-banner Have fulfilled the conditions 1) Manifest file { "name": "Project clean as pwa", "short_name": "Pro Clean", "icons":[ { "src": "/icons/icons8-washing-machine-48.png", "type": "image/png", "sizes": "48x48" }, { "src": "/icons/icons8-washing-machine-96.png", "type": "image/png", "sizes": "96x96" }, { "src": "/icons/app-icon-192x192.png", "type": "image/png", "sizes": "192x192" }, { "src": "/icons/icons8-washing-machine-480.png", "type": "image/png", "sizes": "480x480" }, { "src": "/icons/icons8-washing-machine-512.png", "type": "image/png", "sizes": "512x512" } ], "start_url":"/initial", "scope": "../", "display":"standalone", "orientation":"any", "background_color":"#fff", "theme_color":"#3f51b5", "description":"Simple dry clean description", "dir":"ltr", "lang":"en-US" } 2) Registered service worker- src/js/application.js if("serviceWorker" in navigator){ navigator.serviceWorker.register('/sw.js') .then(function(){ console.log("Service worker registered"); }); }; 3) Added fetch event handler in serviceworker file- /sw.js self.addEventListener("fetch",function(event){ event.respondWith(fetch(event.request)); }); 4) Saving beforeinstallprompt event for later use - src/js/application.js window.addEventListener("beforeinstallprompt",function(event){ console.log("beforeinstallprompt fired");//this never appears after waiting for long event.preventDefault(); event.prompt(); deferredPrompt = event; return false; }); 5) Using the event late. Gets called on clicking 'Collect' button present in /initial- src/js/collection.js function collectOrder(){ console.log("Using the event ", deferredPrompt);//on call of the funtion the event comes undefined if(deferredPrompt){ deferredPrompt.prompt(); deferredPrompt.userChoice.then(function(choiceResult){ console.log(choiceResult.outcome); if(choiceResult.outcome==="dismissed") console.log("User cancelled installation"); else console.log("User added to homescreen"); }); deferredPrompt = null; }; } 6) The lighthouse test says the app is pass for "install banner" What is the expected result? The banner should appear. What happens instead of that? The banner never appeared. Please provide any additional information below. Attach a screenshot if possible. UserAgentString: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
,
May 28 2018
,
May 28 2018
@brajminator: Could you please respond to comment #2? Thanks!!
,
Oct 9
Closing this issue due to lack of feedback from reporter. Please feel free to raise a new issue if this is still seen. Thanks! |
||||
►
Sign in to add a comment |
||||
Comment 1 by dominickn@chromium.org
, May 25 2018Labels: -OS-Windows OS-Android