import{App}from'@capacitor/app';import{BackgroundTask}from'@capawesome/capacitor-background-task';App.addListener('appStateChange',async({isActive})=>{if(isActive){return;}// The app state has been changed to inactive.// Start the background task by calling `beforeExit`.consttaskId=awaitBackgroundTask.beforeExit(async()=>{// Run your code...// Finish the background task as soon as everything is done.BackgroundTask.finish({taskId});});});