Backgroud task never execute on watch

Hi everyone! I'm writing a watch app using backgroud refresh. But the backround task was not triggered either on simulator or real watch device.

Thanks for the post. I’m not the best person to answer watchOS questions, but this one looking in your code should be straightforward.

The watchOS simulator does not run the background task scheduler the same way a real device does. If your app does not have a complication on the user's active watch face, your background execution budget is extremely limited. I would recommend to add a complication for your app to your active watch face and try again. Make sure in your project that in Signing & Capabilities tab. If you don't see "Background Modes", click the + Capability button and add it. Check the box for background fetch

I don’t see in your code the import nor the WKApplicationDelegate nor you scheduling a task with using WKExtension.shared().scheduleBackgroundRefresh(…)?

On a real Apple Watch, the system will suppress background tasks if the watch battery is low, low Power Mode is turned on. Try the Debug > Simulate Background Fetch in Xcode first to ensure your handle(_ backgroundTasks:) code is wired up correctly. If that works, add your complication to the watch face, schedule a task for 15 minutes in the future, put the app in the background, and wait.

Hope this helps

Albert  WWDR

Backgroud task never execute on watch
 
 
Q