box / box/box-ios-sdk

Add Support for Background Sessions and Delegate-Based API

Open
#1,200 1 comment 0 reactions 6 assignees Claimed by @mwwoda View on GitHub
enhancement
Dominant language
Swift
Stars
130
Forks
111
Avg merge
17h 58m
Merged PRs (30d)
13

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](https://github.com/box/box-swift-sdk-gen/blob/a6b5793ab4053f9b55b840245ad07c9e3fdae344/Sources/Networking/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`](https://developer.apple.com/documentation/foundation/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 `URL`s instead of `InputStream`s 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 `URL`s for upload tasks.

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.