box / box-swift-sdk-gen

Repository for Box Swift autogenerated SDK
Apache License 2.0
8 stars 2 forks source link

Add Support for Background Sessions and Delegate-Based API #237

Open tobihagemann opened 2 days ago

tobihagemann commented 2 days ago

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:

My changes can be viewed here: https://github.com/tobihagemann/box-swift-sdk-gen/compare/a6b5793ab4053f9b55b840245ad07c9e3fdae344...b2bb9db3b4fc5e86807f3c5043bedcab9fdf48f7

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.

arjankowski commented 2 days ago

Hi @tobihagemann,

Thank you for your support in the development of our SDK ❤️

Your change looks fine, however, as you mentioned, our SDK is generated, so implementing this requires significant additional effort from us. Additionally, by adding a URL here instead of an InputStream, we are changing the contract we have in our codegen compared to other languages, which further complicates the matter.

At the moment, we cannot implement this, but we will definitely do it before the official release. We are leaving the ticket open, as soon as we add it, we will inform you.

Thank you once again for your support in our new box-swift-sdk-gen.

Best regards Artur