Search completed in 1.17 seconds.
BeforeInstallPromptEvent - Web APIs
om its parent, Event. BeforeInstallPromptEvent.platforms Read only Returns an array of DOMString items containing the platforms on which the event was dispatched. This is provided for user agents that want to present a choice of versions to the user such as, for example, "web" or "play" which would allow the user to chose between a web version or an Android version. BeforeInstallPromptEvent.
userChoice Read only Returns a Promise that resolves to a DOMString containing either "accepted" or "dismissed". Methods BeforeInstallPromptEvent.prompt() Allows a developer to show the install prompt at a time of their own choosing. This method returns a Promise. Example window.addEventListener("beforeinstallprompt", function(e) { // log the platforms provided as options in an install prompt...
...ither "accepted" or "dismissed". ...
Add to Home screen - Progressive web apps (PWAs)
an be triggered later. ...
...ser to click. Set a click handler for the button. The click handler contains the following steps: Hide the button again with display: none -- it is no longer needed once the app is installed. Use the prompt() method available on the beforeinstallprompt event object (stored in deferredPrompt) to trigger showing the install prompt. Respond to the user's interaction with the prompt using the
userChoice property, again available on the beforeinstallprompt event object. Set deferredPrompt to null since it is no longer needed. So when the button is clicked, the install prompt appears. If the user selects Install, the app is installed (available as standalone desktop app), and the Install button no longer shows (the onbeforeinstallprompt event no longer fires if the app is already installed).