In my service worker, I'm implementing background sync with workbox like so
workbox.routing.registerRoute(
options => options.url.pathname.startsWith('/api/'),
new workbox.strategies.NetworkOnly({
plugins: [
new workbox.backgroundSync.Plugin('myQueueName', {
maxRetentionTime: 14 * 24 * 60,
onSync() {
showNotification('background sync ran.');
}
})]
}),
'POST'
);
When I test the behavior by disabling network access, executing a request and then turning network access back on, I'm seeing the notification that is triggered in showNotification
, but I'm not seeing the actual requests.
Oddly enough, when I remove the onSync
callback, I'm now seeing the requests but obviously, I'm not creating any notifications. How can I get a callback and have the actual requests replayed?