New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 846608 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Oct 9
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

beforeinstallprompt not firing automatically

Reported by brajmina...@gmail.com, May 25 2018

Issue description

Chrome 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



 
Components: UI>Browser>WebAppInstalls
Labels: -OS-Windows OS-Android
I tested the site on Android and saw "beforeinstallprompt fired" in the devtools console (logged from application.js). If you've already added the site to home screen, or the banner has already been shown to the user, it won't be shown again. Try removing it and clearing Chrome's data - if you still can't get beforeinstallprompt to fire after then, please report back.

The banner won't be seen on Windows since we haven't enabled the feature on Windows yet.
Labels: Needs-triage-Mobile
Cc: sandeepkumars@chromium.org
Labels: Triaged-Mobile Needs-Feedback
@brajminator: Could you please respond to comment #2?

Thanks!!
Cc: chelamcherla@chromium.org
Status: WontFix (was: Unconfirmed)
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