Notiser
Förkortningar
- APN - Apple Push Notification
- APNS - Apple Push Notification Service
Kontrollera om det finns stöd
if (!("Notification" in window)) {
Beviljad
Notification.permission === "granted"
Nekad
Notification.permission !== 'denied'
Fråga om tillåtelse
Notification.requestPermission(function (permission) {
Ny notis
var notification = new Notification("yeah");
Exempel med JavaScript
if (!('Notification' in window)) {
alert('This browser does not support desktop notification');
} else if (Notification.permission === 'granted') {
const notification = new Notification('Hello world');
} else if (Notification.permission !== 'denied') {
Notification.requestPermission().then((permission) => {
if (permission === 'granted') {
const notification = new Notification('Hello world');
}
});
}
Testa här
Electron.js