I setup a BGProcessingTask that do some work with the db and at the end sends an email. I've notice that, even if I set requiresExternalPower to false the task runs only when the device is connected to the power cable. I've tested setting the repeating time every 10 minutes. If the power cable is disconnected the task isn't launhed anuymore. After I attach the cable, waiting some minutes it restarts.
BGProcessingTask starts only if connected to power even if requiresExternalPower is NO
When you clear
requiresExternalPower
that just means your task
can run without external power. The BackgroundTasks framework is still free to decide when to run it, and it uses its own internal criteria to make that decision.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
ps DTS is closed 21 Dec through 1 Jan.
OK, I understand it. But it's very strange that in a month of tests the only times that the background task is launched is when the device is connected to external power. WhenI connect to power the task is launched after one or two minutes. If I disconnect the power cable the task is never launched, NEVER. So I understand that the system can decide, but it seems that on my app this is a base condition. Maybe there's something else I can change, but what?
So I understand that the system can decide, but it seems that on my app this is a base condition.
Or maybe that’s the current system policy for all apps. It’s not uncommon for system frameworks to give themselves a lot of latitude to allow for future changes.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
Have you found any solution for above issue ? we are also facing same issue.
Thank you
Code Block
Again, that’s within the range of allowed behaviours.The system NEVER run the task without the connection to power.
If you’re interested in more background (hey hey) on how this stuff works in practice, watch WWDC 2020 Session 10063 Background execution demystified.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
we are facing same this problem. BGProcessingTask starts only if connected to power . I watched the watch WWDC 2020 Session 10063 Background execution demystified. But I don't think the decision is exactly when my testing device is only running 1 application and other services I try to disable it. My testing device is also fully charged before testing.