So currently, i'm working with an app that is written in react and has a service worker script. It is rendered on a Honeywell CT40 device via an Android hardware abstraction layer through a webview in the android/java code. Everything seems to work fine in the chrome browser when running the react app only. However, when the android app runs and renders the app, the service worker fails to register. The only error message I get on the chrome logs are:
Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://storage.googleapis.com/workbox-cdn/releases/5.1.2/workbox-sw.js' failed to load.
This error only occurs when visiting the app through the android app via webview, but when using the browser directly, no issues.
Any thoughts?
WebView version: 79.0.3945.116
WebView version: com.android.chrome
Again, this works as expected in the browser itself, just not in the android webview browser it seems. Any idea? Attached are screenshots. Below is a code sample of where the service worker script starts. As stated in the documentation here: https://developer.chrome.com/docs/workbox/modules/workbox-sw/
/* eslint-disable */
importScripts(
'https://storage.googleapis.com/workbox-
cdn/releases/5.1.2/workbox-sw.js'
);
let window = self
importScripts('/__ENV_FILE__.js')
workbox.setConfig({
debug: window.$$.APP_WORKBOX_CONFIG_DEBUG || false
})
const { precacheAndRoute, createHandlerBoundToURL } = workbox.precaching
const { NavigationRoute, registerRoute } = workbox.routing
const { NetworkOnly } = workbox.strategies
const { Queue } = workbox.backgroundSync
// Injection point of precache assets
precacheAndRoute(self.__WB_MANIFEST)
self.addEventListener('message', (event) => {
if (event.data && event.data.type === 'SKIP_WAITING') {
self.skipWaiting()
}
})