This is a small library for handling install Banner for Progreww Web Application(PWA).
No dependency
yarn add install-prompt
import InstallPrompt from 'install-prompt';
// initial installPrompt
const installPrompt = new InstallPrompt();
// add 1 count when user do some interactive
installPrompt.addCount();
// check if prompt should popup
installPrompt.checkPrompt();
import InstallPrompt from 'install-prompt';
...
componentDidMount() {
this.installPrompt = new InstallPrompt();
this.installPrompt.addCount();
}
componentWillReceiveProps(nextProps) {
if (nextProps.cid !== this.props.cid) {
this.installPrompt.addCount().checkPrompt();
}
}
-
promptKey: (string) default is 'installPrompt'
-
minimumPrompt: (number) default is 2
e.g,
const installPrompt = new InstallPrompt({
promptKey: 'custom-localstorage-key',
minumumPrompt: 5
});
yarn dev
yarn test