If we start uploading a video file from the foreground and then switch to another app or press the home button, we can enable background processing by selecting the 'Background processing' option in the app's background modes. We utilize URLSession
to handle the upload. I have a few questions regarding this process:
- If the user manually kills the app, will the upload continue in the background?
- For files around 100 MB, if the user locks the phone while the upload is in progress (and the app is in the background but not terminated), will the upload still be successful?
- Does Apple provide any additional APIs that would facilitate successful file uploads even if the user terminates the app?
I would appreciate any solutions or insights you can provide. Thank you!
If the user manually kills the app, will the upload continue in the background?
No. If the user manually removes the app from the multitasking API, iOS interprets that as strong sign that the user doesn’t want it running. Given that, it terminates most background activity related to the app, including any tasks in URLSession
background sessions.
For files around 100 MB, if the user locks the phone while the upload is in progress (and the app is in the background but not terminated), will the upload still be successful?
There’s no way to answer that definitively. The user could turn the phone off and then leave it off. However, in general, a URLSession
background session should be able to deal with a 100 MB upload just fine.
Does Apple provide any additional APIs that would facilitate successful file uploads even if the user terminates the app?
No.
However, there are things you can do to improve the reliability of your uploads, including:
-
Support upload resumption on the server. See WWDC 2023 Session 10006 Build robust and resumable file transfers.
-
Consider using a background processing request, which typically runs overnight, as a backstop. See iOS Background Execution Limits for more on that topic.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"