Test service worker
This commit is contained in:
@ -45,10 +45,21 @@ export default function Layout() {
|
||||
async function goToNotifications(e: any) {
|
||||
e.stopPropagation();
|
||||
// request permissions to send notifications
|
||||
if ("Notification" in window && Notification.permission !== "granted") {
|
||||
if ("Notification" in window) {
|
||||
try {
|
||||
let res = await Notification.requestPermission();
|
||||
console.debug(res);
|
||||
if (Notification.permission !== "granted") {
|
||||
let res = await Notification.requestPermission();
|
||||
console.debug(res);
|
||||
}
|
||||
if (Notification.permission === "granted") {
|
||||
let worker = await navigator.serviceWorker.ready;
|
||||
worker.showNotification("Vibration Sample", {
|
||||
body: "Buzz! Buzz!",
|
||||
icon: "../images/touch/chrome-touch-icon-192x192.png",
|
||||
vibrate: [200, 100, 200, 100, 200, 100, 200],
|
||||
tag: "vibration-sample",
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user