const status = await BackgroundFetch.configure({
minimumFetchInterval: 15
}, async (taskId) => {
console.log('[BackgroundFetch] EVENT:', taskId);
// Perform your work in an awaited Promise
const result = await this.performYourWorkHere();
console.log('[BackgroundFetch] work complete:', result);
// [REQUIRED] Signal to the OS that your work is complete.
BackgroundFetch.finish(taskId);
}, async (taskId) => {
// The OS has signalled that your remaining background-time has expired.
// You must immediately complete your work and signal #finish.
console.log('[BackgroundFetch] TIMEOUT:', taskId);
// [REQUIRED] Signal to the OS that your work is complete.
BackgroundFetch.finish(taskId);
});
The third argument, the timeout handler, is an async function, but the comment indicates that I must complete my work "immediately," and the only operation performed in this example is a console.log (synchronous). I'm a bit confused as to whether I can perform async cleanup work in this handler. If so, what are the implications of delay here?
In the docs, the following example is given:
The third argument, the timeout handler, is an async function, but the comment indicates that I must complete my work "immediately," and the only operation performed in this example is a console.log (synchronous). I'm a bit confused as to whether I can perform async cleanup work in this handler. If so, what are the implications of delay here?