Reputation: 21
I'm making an app where I upload multiple Images and Videos using Alamofire 5.2. The upload might take long time because the file sizes might be big and making the user wait for upload is not what I want. So I let the user explore the app and keep uploading in background. When the app is in foreground or background the upload task gets successful with no issues. Now, what if the user or the OS killed the app before the upload could finish? The solution that comes to mind is to resume upload where we left off if the app was launched again. I tried looking for solutions but couldn't really find what I was looking for. If Alamofire can't do it then maybe URLSession can do it. I would really appreciate it if anyone can help me with this.
Upvotes: 0
Views: 369
Reputation: 12800
If the user manually kills the app there's nothing you can do as the app is killed immediately with no opportunity to record the upload position. You could potentially add an API to your backend to check if there was an upload active and see if it can be resumed, but locally there's nothing to do.
If the OS kills the app in the background, then a background URLSession
may help. Alamofire does not support background sessions so you'd need to do it manually.
Upvotes: 0