How to download data while Android/iOS app is minimized or put into background?

Unity 2019.4.20f1, Addressables 1.18.4, Android Player, iOS Player

We use Addressables.DownloadDependenciesAsync to download bundles from Unity Cloud Content Delivery.

Minimizing or putting the app into background pauses the download. Bringing the app into foreground resumes the download again.

Is there a way to continue downloading the content while the app is minimized or put into background?

I recently solved this exact problem by implementing custom Bundle provider. To my knowledge, there is no way you can continue download when app is minimized. It may even be unloaded entirely. To support this out of the box, Unity needs to add some magic to UnityWebRequest and use some kind of system service for background downloading.

In my case I solved this by using DownloadManager class natively on Android. (no solution for iOS yet - there was no need)

2 Likes

I would actually like to hear some thoughts from the developers on it. Is such feature planned? From an users perspective, it’s not a great experience to require to keep the game in the foreground to download the files. @TreyK-47

1 Like

As far as I’m aware the app is allowed a certain amount of time to continue to do things while in the background. But its only <20 sec as far as I’m aware.
I have a multiplayer game and you can minimise the app and reopen it within that time and the sockets will stay connected, any longer than that and they dissconnect due to the OS killing all activity.
So unless your download can complete in that time, I doubt there is any way to do it without running a background service and even then you are very limited on what you can do.

1 Like

I’ll forward this over to the team, see if they have some guidance to share.

1 Like

For the record, if you want to implement this yourself in the addressables system you can use com.unity.networking.backgrounddownload. It abstracts away the differences between iOS and Android.

It looks like others have provided the answers, so I will just confirm.

Addressables uses UnityWebRequest which has no resume or background download functionality.
For iOS and Android you need to use native download methods which the package @AlkisFortuneFish mentioned handles.
In order to implement this, you will need a custom AssetBundleProvider that uses that to download (Take note that you remember to do caching and recompression).
We currently have no schedule to move from UnityWebRequest add this functionality at this time.

1 Like

Since this is something in highly required for mobile platforms, can you please provide a small example or a documentation link on how to do it?
Thanks

Is there any documentation for guidance on implementing this?