Skip to content

Instantly share code, notes, and snippets.

@alieslamifard
Created September 6, 2019 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alieslamifard/559448f4448200f21acdf561c38f681e to your computer and use it in GitHub Desktop.
Save alieslamifard/559448f4448200f21acdf561c38f681e to your computer and use it in GitHub Desktop.
const [installationStatus, installationEvent] = useInstallPrompt(true);
useEffect(() => {
// installationStatus is one of these states: null/dismissed/accepted/installed
if(installationStatus === 'accepted') {
// User accept it. You can save it in some log with device config.
}
// Show Add-to-home-screen prompt, if user have it's condition.
if(installationEvent) {
installationEvent.prompt();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment