Reputation: 13
I want to know about the behaviour of NSURLSessionDataTask in background.
Does NSURLSessionDataTask get paused right away (as soon as the app enters background)? or does iOS give some time hopefully 30 seconds or so until the response ?
Upvotes: 1
Views: 532
Reputation: 27428
No, You will not continue with NSURLSessionDataTask
in background mode with defaultSessionConfiguration
!
If you want to continue execution in background then you need to configure session with backgroundSessionConfiguration
.
When you are using backgroundSessionConfiguration
you can't send data
directly to server, you have to give file url and from that url you have to send bytes or chunks to server, and you have to use uploadTask
or downloadTask
with backgroundSessionConfiguration
!!
If you wants little time after entering in background then you can use UIBackgroundTaskIdentifier
. These are very huge concepts to explain every thing here, It's better that you read documentations from apple or some tutorial for that!!! You should refer Apple Documentation for Background Execution and Apple documentation for NSURLSession !
Upvotes: 1