-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Is your feature request related to a problem? Please describe.
The current Box SDK library does not support background sessions. An error is thrown at NetworkClient.swift#L86 with the message: Completion handler blocks are not supported in background sessions. Use a delegate instead.
Additionally, the library does not differentiate between request types for creating background-compatible upload tasks, which are necessary for handling uploads in the background. This lack of support limits the SDK's utility for apps that need to perform background uploads (and downloads).
Describe the solution you'd like
I would like the SDK to support background sessions by transitioning from a callback-based API to a delegate-based API. Specifically, there should be differentiation in request creation to use URLSessionUploadTask, as this type of task allows for uploads in the background, unlike data tasks.
This change would require modifying the API to accept file URLs instead of InputStreams to comply with the requirements of URLSessionUploadTask and enable background operation.
Describe alternatives you've considered
I have already forked the repository and made the necessary changes to support background sessions by:
- Refactoring the API to use delegates instead of callbacks.
- Differentiating request creation to use
networkSession.session.uploadTask()as well. - Switching from
InputStreamto fileURLs for upload tasks.
My changes can be viewed here: tobihagemann/box-swift-sdk-gen@a6b5793...b2bb9db
However, since this project appears to be generated, integrating these changes directly through a PR may not be practical due to the extent of the modifications, resulting in hundreds of lines of code changes.