Я создаю PWA с React (CRA), и у меня возникают проблемы с Service Worker от OneSignal.
My OneSignalSDKWorker:
importScripts('https://pwa.yeapps.com.br/service-worker-custom.js');//My custom service worker
importScripts('https://cdn.onesignal.com/sdks/OneSignalSDKWorker.js');
My OneSignalSDK:
importScripts('https://cdn.onesignal.com/sdks/OneSignalSDK.js');
Мой индекс. html:
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('OneSignalSDKWorker.js').then(function (registration) {
console.log('Worker registration successful', registration.scope);
}, function (err) {
console.log('Worker registration failed', err);
}).catch(function (err) {
console.log(err);
});
});
} else {
console.log('Service Worker is not supported by browser.');
}
Но я получил ошибку при сборке приложения и загрузке файлов: