Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tobihagemann opened this issue Sep 16, 2024 · 1 comment
Open

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

tobihagemann opened this issue Sep 16, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@tobihagemann
Copy link

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 InputStream to file URLs 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.

@arjankowski
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants