BeforeInstallPrompt

This article needs a technical review. How you can help.

 

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The BeforeInstallPromptEvent is passed into the onbeforeinstallprompt handler and displatched when a web manifest exists, but before a user is prompted to save a web site to a home screen on mobile.

This interface inherits from the Event interface.

Constructor

BeforeInstallPromptEvent.BeforeInstallPromptEvent()
Creates a new BeforeInstallPromptEvent.

Properties

Inherits properties from its parent, Event.

BeforeInstallPromptEvent.platform Read only
Returns a DOMString containing the platform on which the event was dispatched.
BeforeInstallPromptEvent.userChoice Read only
Returns a Promise that resolves to a DOMString containing either 'installed' or 'dismissed'.

Example

window.addEventListener("beforeinstallprompt", function(e) { 
  // log the platforms provided as options in an install prompt 
  console.log(e.platforms); // e.g., ["web", "android", "windows"] 
  e.userChoice.then(function(platform, outcome) { 
    console.log(platform); // the platform of the app the user took an action on 
    console.log(outcome); // either "installed", "dismissed", etc. 
  }, handleError); 
});

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support

44.0 [1]

Not supported Not supported Not supported Not supported
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support Not supported

44.0 [1]

Not supported Not supported Not supported Not supported

44.0 [1]

[1] beforeinstallprompt event is supported in Chrome 44, but it is behind the flagchrome://flags/#bypass-app-banner-engagement-checks

Document Tags and Contributors

 Contributors to this page: rolfedh, jpmedley, jsx
 Last updated by: rolfedh,