pCloud / pcloud-sdk-swift

The official pCloud Swift SDK for iOS and macOS for integration with the pCloud API.
MIT License
22 stars 7 forks source link

Support for background URLSession #18

Closed phil1995 closed 2 years ago

phil1995 commented 2 years ago

Are there any plans to support background URLSession? We would like to use a background URLSession for larger uploads/downloads in our project.

tmpit commented 2 years ago

Hey, there are currently no plans to add official support for background sessions. At least for the next quarter.

That being said, it is currently possible to create a PCloudClient with a background URLSession, although not in a very obvious way. You can take a look at the implementation of

func createClient(withAccessToken accessToken: String, apiHostName: String) -> PCloudClient

method in PCloud.swift. All of the building blocks of a PCloudClient are public. You just need to use a different URLSession. However, the SDK does not currently make it easy to use a background session. For example, you might want to persist URLSessionTask identifiers so on the next process instance you know which files are still uploading/downloading or finished. That will not be possible unless you intercept URLSessionTask creation. Which can be done but it requires non-superficial knowledge into the inner workings of the SDK and not something clients of the SDK should have to do.

Can you tell me what you need the SDK to offer other than just injecting a URLSession? It will be helpful once we get around to making enhancements to the SDK.

tmpit commented 2 years ago

Closing due to inactivity.