I can get the sync to work and clear out the IndexedDB queue but the data is not being stored in my mysql database. Is there something I am missing?
My service worker:
importScripts('https://storage.googleapis.com/workbox-cdn/releases/6.1.1/workbox-sw.js');
// This is the "Offline copy of assets" service worker
const CACHE = "pwabuilder-offline";
const SYNC = "bgSync"
const QUEUE_NAME = "bgSyncQueue";
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});
workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.NetworkFirst({
cacheName: CACHE
})
);
const bgSyncPlugin = new workbox.backgroundSync.BackgroundSyncPlugin(QUEUE_NAME, {
maxRetentionTime: 24 * 60 // Retry for max of 24 Hours (specified in minutes)
});
workbox.routing.registerRoute(
new RegExp('^https:\/\/domain.com\/[a-zA-Z]+\/journal'),
new workbox.strategies.NetworkOnly({
plugins: [bgSyncPlugin]
}),
'POST'
);
Well, turned out background sync doesn't like to be tested within a browser. Tried it from my phone via the installed app and it works fine.