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 Window.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'.

Methods

BeforeInstallPromptEvent.prompt() 
Allows a developer to show the install prompt at a time of their own choosing. This method returns an empty Promise.

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]

No support No support No support No support
prompt() method. 45.0 [1] No support No support No support No support
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support

44.0 [1]

No support No support No support No support

44.0 [1]

prompt() method. No support 45.0 [1] No support No support No support No support 45.0 [1]

[1] Behind the flagchrome://flags/#bypass-app-banner-engagement-checks

Document Tags and Contributors

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