dotnet / dotnet/macios

Add support for background file downloads

Open
#24,397 0 comments 0 reactions 0 assignees View on GitHub
api-bindings networking
Dominant language
C#
Stars
2.9k
Forks
576
Avg merge
2d 13h
Merged PRs (30d)
96

Description

### 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 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](https://github.com/dotMorten/iosBackgroundDownload/blob/main/src/NSUrlSessionHandler.FileDownload.cs).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.