Skip to content

Instantly share code, notes, and snippets.

View petronioamaral's full-sized avatar

Petrônio Amaral petronioamaral

  • Dublin, Ireland
View GitHub Profile
@Uriel29
Uriel29 / app.js
Last active November 8, 2023 01:24
Instalar PWA com botão que aparece assim que o Service esta registrado e o beforeinstallprompt esta funcional! Deixei o botão como none:
window.onload = function() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js').then(function() {
console.log('Service Worker Registered');
});
}
let deferredPrompt;
const addBtn = document.querySelector('#enable-banner-install');
window.addEventListener('beforeinstallprompt', (e) => {