I make react app from Create React App then use default config PWA. But i got confused how to hide button add to screen. Any one can help me? thank you
Advertisement
Answer
You need to prevent the installation:
JavaScript
x
4
1
window.addEventListener('beforeinstallprompt', (e) => {
2
e.preventDefault()
3
})
4
In addition you can save the installation event and create a custom install button:
JavaScript
1
11
11
1
let installEvent;
2
window.addEventListener('beforeinstallprompt', (e) => {
3
e.preventDefault()
4
installEvent = e;
5
})
6
7
8
button.onclick = () => {
9
installEvent.prompt()
10
}
11