私はReact、Redux、およびサービスワーカーを自分のアプリケーションで使用しており、サービスワーカーのReduxストアにアクセスしたいと考えています。Reduxサービス勤務者へのアクセス方法
マイサービスワーカーは次のとおりです。
function checkCompatibility() {
if ('serviceWorker' in navigator && 'PushManager' in window) {
console.log('Service Worker and Push is supported');
navigator.serviceWorker.register('./sw.js')
.then(function (swReg) {
console.log('Service Worker is registered', swReg);
})
.catch(function (error) {
console.error('Service Worker Error', error);
});
} else {
console.warn('Push messaging is not supported');
}
}
function askForNotification() {
if (!('Notification' in window)) {
console.log('This browser does not support desktop notification');
} else if (Notification.permission === 'granted') {
console.log('Permission granted.');
} else if (Notification.permission !== 'denied' || Notification.permission === 'default') {
Notification.requestPermission(function (permission) {
if (permission === 'granted') {
var notification = new Notification('Permissão de Notificação foi Aceita', { icon: '/favicon.png', badge: '/favicon.png' });
}
});
}
}
checkCompatibility();
askForNotification();
誰も私を助けることができますか?
をインストールしてインストールします。コール。 –