/ / да създадете известие за натискане в интернет (не за приложение за Android, а само за уебсайт)? - javascript, php

да създадете известие за натискане в интернет (не за Android приложение, а само за уебсайт)? - javascript, php

Преминах през толкова много уеб страници, но не успях да намеря подходящ отговор, можеш ли да ми помогнеш с него. Искам да знам как може да се създаде уведомление за уеб натискане (не за Android приложение, а само за уебсайт)?

Отговори:

0 за отговор № 1

Можете просто да добавите този ред код:

var myNotification = new Notification(title, options);

Давам ти по-добър пример, трябва да помолиш потребителя, ако можеш да добавиш известия:

function notifyMe() {
// Let"s check if the browser supports notifications
if (!("Notification" in window)) {
console.log("This browser does not support desktop notification");
}

// Let"s check whether notification permissions have alredy been granted
else if (Notification.permission === "granted") {
// If it"s okay let"s create a notification
var notification = new Notification("Hi there!");
}

// Otherwise, we need to ask the user for permission
else if (Notification.permission !== "denied" || Notification.permission === "default") {
Notification.requestPermission(function (permission) {
// If the user accepts, let"s create a notification
if (permission === "granted") {
var notification = new Notification("Hi there!");
}
});
}

// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them any more.
}

Можете да се консултирате с Документацията на MDN и Спецификацията на MDN.