I try to activate a background-sync, but i run to error when I typing the code. Why can't find it?
Should i update something?
My code:
if ('periodicSync' in worker) {
const status = await navigator.permissions.query({
name: 'periodic-background-sync', //ERROR
});
// Periodic background sync can be used.
if (status.state === 'granted') {
const tags = await worker.periodicSync.getTags(); //ERROR
if (!tags.includes('sendDbDatas')) {
worker.periodicSync.register('sendDbDatas'); //ERROR
}
} else {
// Periodic background sync cannot be used.
}
}
I see typings doesn't allow the value 'periodic-background-sync'.
interface DevicePermissionDescriptor extends PermissionDescriptor {
deviceId?: string;
name: "camera" | "microphone" | "speaker";
}
as a workaround, you can use casting to any.
const status = await navigator.permissions.query({
name: <any>'periodic-background-sync'
});
Looking into Web Periodic Background Synchronization draft I would be brave enough to say this periodic sync is a modern feature that is not mature yet. No surprise typings are not aware of it.