Skip to content

Add support for background file downloads #24397

@dotMorten

Description

@dotMorten

Apple platform

iOS + Catalyst

Framework version

net9.0-*

Affected platform version

.NET 8+

Description

I've been experimenting with allowing you to do large file downloads on iOS even if the app is getting backgrounded.
The current HttpMessageHandler.SendAsync doesn't really support this approach, so for now in my experiment I added a new Task<HttpResponse> DownloadFileAsync(...) method to NSUrlSessionHandler to support this.
This might not be the best way to do it, but it was one way I could simply do it while piggybacking on all the other work there's already in NSUrlSessionHandlerDelegate.

I think there's room to consider adding some better support for this in the .NET iOS SDK, and I'm creating this issue to initiate those discussions.

Steps to Reproduce

I have a sample repository with a forked version of NSUrlSessionHandler. I tried keeping my changes to a separate file, which thanks to all the partial classes was pretty easy to do.

Repo here: https://github.com/dotMorten/iosBackgroundDownload/

Main additions are all in this file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-bindingsnetworkingIf an issue or pull request is related to networking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions