Background Upload Extension

Hello, We are trying to use the new Background Upload Extension to improve uploads of assets (Photos, Live Photos, Videos) in the background in our application.

1 - We implemented the code to upload still images. We would like to do the same for Live Photos but we are not sure how to proceed since a Live Photo is composed of 2 resources that we would like to upload in the same job so that we keep the association between the 2 resources. Steps: A Live Photo is captured on the device. Our application is notified for new content in the Photo Library and the asset is queued for upload by our application. The system calls the background upload extension and the Live Photo is prepared for upload but we can schedule a job only for one resource (still photo or paired video) so we can not upload both resources in a single job.

2 - Is there a way to synchronise the application and the extension so that the application would not process the same data or execute the same requests than the extension. For example: our application is working with tokens and we would like to prevent those tokens to be consumed by the application and the extension at the same time.

3 - is there a command in xcode or terminal to start or stop the extension, something similar to what exists for processing tasks (https://developer.apple.com/documentation/backgroundtasks/starting-and-terminating-tasks-during-development).

1 - We implemented the code to upload still images. We would like to do the same for Live Photos, but we are not sure how to proceed since a Live Photo is composed of 2 resources that we would like to upload in the same job so that we keep the association between the 2 resources.

I think your only option here is to process the assets as separate jobs and use the URL request to preserve the conceptual link between the assets— for example, embedding that information in the upload URL or in the URL metadata.

2 - Is there a way to synchronise the application and the extension so that the application would not process the same data or execute the same requests as the extension? For example: our application is working with tokens, and we would like to prevent those tokens from being consumed by the application and the extension at the same time.

These issues are alluded to at the end of this section where it says:

"Important Your extension needs a mechanism to track which assets you’ve already processed and detect new ones. This typically involves persistent storage shared between your app and extension using an app group. Use fetchPersistentChanges(since:) with a PHPersistentChangeToken to track your progress."

3 - Is there a command in Xcode or Terminal to start or stop the extension?

There is not, however. I also think we're pretty aggressive about interacting with your extension, so that shouldn't necessarily matter.

Something similar to what exists for processing tasks

Keep in mind that the normal scheduling behavior for processing tasks to run is basically "once per day in the middle of the day while you're sleeping and specifically NOT using your device". The debugging trigger was included because the expected scheduling behavior for processing is about as hostile to active debugging as it's possible to be.

I mean that quite literally, as I think the basic workflow of running your app through Xcode generates enough activity that processing task will never fire. Without that hook, it would effectively be impossible to test or debug BGProcessingTask.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Background Upload Extension
 
 
Q