Can we access the Workbox background sync queue object in outside service worker file, in any of my application files say index.php?
1 Answers
0
votes
I believe you can use the BroadcastChannel API, something like this:
// From Service Worker, connect to the channel named "my_bus".
const channel = new BroadcastChannel('my_bus');
// Send a message on "my_bus".
channel.postMessage('This is a test message.');
// From client, listen for messages on "my_bus".
const channel = new BroadcastChannel('my_bus');
channel.onmessage = function(e) {
console.log('Received', e.data);
};