Search Unity

UnityWebRequest: How to continue the web request even when app in pause?

Discussion in 'Scripting' started by cdytoby, Apr 3, 2017.

  1. cdytoby

    cdytoby

    Joined:
    Nov 19, 2014
    Posts:
    181
    We have an optional requirement that when downloading a file, the download process should continue regardless of the app is paused or not.

    Formally I used WebRequest within System, but due to the cerification issue I cannot resolve, and the availbility of UnityWebRequest, I use UnityWebRequest and DownloadHandlerScript instead.

    But The problem is, the UnityWebRequest will also pause when app is paused.

    How to continue the download even when the app is paused?
     
  2. chris_unity559

    chris_unity559

    Joined:
    Mar 26, 2019
    Posts:
    12
    Any response on this?
     
  3. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    u talking about async ops for dl'ing?
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    It depends on the platform and exact requirements.
    If you are on Android, iOS or UWP, the best option is to use our BackgroundDownload plugin: https://github.com/Unity-Technologies/BackgroundDownload
    Note, that the latest master version is in progress to be turned into package. For now you'd have to manually put into your Packages folder.

    On other platforms the best option is to use DownloadHandlerFile, that should keep doing an actual download even when app is suspended (granted, it will only become "done" when app is resumed).