install-prompt-banner
This is a small library for handling install Banner for Progressive Web Apps(PWA).
Why
When developing Progressive Web Apps(PWA), the timing of Install App Banner is confused. The default prompt behavior is not cool for users. I create a simple count way to decide the timing of the install banner. This library is very tiny which is implemention from Deferring or cancelling the prompt https://developers.google.com/web/fundamentals/app-install-banners/. You can add it with whatever user's interaction in your web site.
For example,
- click "Call to Action" 3 times
- check latest more than 3 times
- viewed more than 2 pages.
Dependency
No dependency
Install
yarn add install-prompt-banner
Usage
;// initial installPromptBannerconst installPromptBanner = ;// add 1 count when user do some interactiveinstallPromptBanner;// check if prompt should popupinstallPromptBanner;
Real example (React)
;...{thisinstallPromptBanner = ;thisinstallPromptBanner;}{if nextPropscid !== thispropscidthisinstallPromptBanner;}
Options
-
promptKey: (string) default is 'installPromptBanner'
-
minimumPrompt: (number) default is 2
e.g,
const installPromptBanner =promptKey: 'custom-localstorage-key'minumumPrompt: 5;
Development
yarn dev
Test
yarn test