Код: Выделить всё
function requestPermission() {
console.log("request permission")
Notification.requestPermission().then((permission) => {
if (permission === 'granted') {
console.log('FIREBASE CLOUD MESSAGING Notification permission granted.');
messaging.getToken(messaging, { vapidKey: '' }).then((currentToken) => {
if (currentToken) {
// Send the token to your server and update the UI if necessary
// ...
console.log("FIREBASE CLOUD MESSAGING currentToken", currentToken)
} else {
// Show permission request UI
console.log('FIREBASE CLOUD MESSAGING No registration token available. Request permission to generate one.');
// ...
}
}).catch((err) => {
console.log('FIREBASE CLOUD MESSAGING An error occurred while retrieving token. ', err);
// ...
});
}
})
}
Подробнее здесь: https://stackoverflow.com/questions/764 ... afari-16-5