1
votes

I am uploading a video using NSURLSession, right now my video is successfully uploaded. but once wifi connection OFF, the below delegate method is executed right away.

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error{
}

How I can resume upload when WIFI connection is back?

1
Which server are you uploading to?Xcoder
@Xcoder We are using Azure server for uploading.QueueOverFlow
Are you uploading file with HTTP? If so once wifi is off whatever you uploaded will be cleared automatically. You need to implement socket to do resume upload after wifi is cut offShinya Koizumi

1 Answers

0
votes

You can do the upload using Background session. If you use the Default session and the wifi goes down while uploading then completion handler runs right away. Due to which you won't be able to do resume when the network comes back. But if you use the Background session and if the wifi goes down while uploading then the completion handler doesn't run until some timeout (resource timeout) occurs. Whenever the wifi is back it either resumes the upload or start it again, depending on the server.

Upload and download tasks in background sessions are automatically retried by the URL loading system after network errors. It is unnecessary to use reachability APIs to determine when to retry a failed task.

Source: URL Session Programming Guide