-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
29 lines (28 loc) · 854 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register("/sw.js")
.then(function (registration) {
console.log(`Registrado com sucesso, escopo é: ${registration.scope}`);
})
.catch(function (err) {
console.log(`Registro falhou, erro: ${err}`);
});
}
function installApp() {
// Show the prompt
deferredPrompt.prompt();
setupButton.disabled = true;
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === "accepted") {
console.log("PWA setup accepted");
// hide our user interface that shows our A2HS button
setupButton.style.display = "none";
} else {
console.log("PWA setup rejected");
setupButton.style.display = "inline";
setupButton.disable = false;
}
deferredPrompt = null;
});
}