BGProcessingTask

I have several questions regarding new BGProcessingTask API


1. It seems that processing tasks are executed only when device is not used at all, i.e. around 5 minutes after device is locked and laying on my table. Is this how it was designed?

2. Background processing is not launched if the application was killed by the user. Is this intended behavior?

3. How does iOS treats the device when it is connected to Mac via USB cable? Is that considered to be external power source?

How do i test/debug background processing task with requiresExternalPower property set to true and false?

Yes, the processing tasks are designed to be executed only when the user is not likely to be using the device.


If the user force quits an app, their background tasks will no longer be executed. This is also by design, and is true for almost every API that allows some amount of background execution.


When the device is plugged to a Mac via the USB cable, it will be considered as connected to external power. To test the requiresExternalPower code paths, you can use wireless debugging by turning on "Connect via network" in Xcode Devices window.


Although, there will be changes in behavior when the app is being debugged. Most importantly, watchdogs will be disabled, that could otherwise terminate your app for various reasons (for example, blocking the main thread). So, it is always best to test background execution in apps while they are running standalone, and use in-app logging mechanisms to help debug.

BGProcessingTask
 
 
Q