Questions tagged [nsurlsessionconfiguration]

An NSURLSessionConfiguration object defines the behavior and policies to use when uploading and downloading data using an NSURLSession object. When uploading or downloading data, creating a configuration object is always the first step you must take. You use this object to configure the timeout values, caching policies, connection requirements, and other types of information that you intend to use with your NSURLSession object.

An NSURLSessionConfiguration object defines the behavior and policies to use when uploading and downloading data using an NSURLSession object. When uploading or downloading data, creating a configuration object is always the first step you must take. You use this object to configure the timeout values, caching policies, connection requirements, and other types of information that you intend to use with your NSURLSession object.

It is important to configure your NSURLSessionConfiguration object appropriately before using it to initialize a session object. Session objects make a copy of the configuration settings you provide and use those settings to configure the session. Once configured, the session object ignores any changes you make to the NSURLSessionConfiguration object. If you need to modify your transfer policies, you must update the session configuration object and use it to create a new NSURLSession object.

NOTE In some cases, the policies defined in this configuration may be overridden by policies specified by an NSURLRequest object provided for a task. Any policy specified on the request object is respected unless the session’s policy is more restrictive. For example, if the session configuration specifies that cellular networking should not be allowed, the NSURLRequest object cannot request cellular networking.

For more information about using configuration objects to create sessions, see NSURLSession Class Reference.

141 questions
1
vote
1 answer

HTTPMaximumConnectionsPerHost,timeoutIntervalForRequest not affecting with defaultSession when used in iOS custom protocol

I am using custom protocol where I create NSURLSession with defaultConfiguration. Here is my code - ` NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; config.timeoutIntervalForRequest =…
1
vote
2 answers

NSURLSessionConfiguration background task on cellular Network not downloading

I am downloading a file from the web. File size is big some times may reach up to 100MBs some times, I want to continue downloading while to app goes to background or when the device is locked. For this i am using AFNetworking…
1
vote
1 answer

defaultSessionConfiguration() works while app is in background

I'm coming across a behavior that is nowhere noted in apple's documentation. I'm making a call over the network using NSURLSession with a NSURLSessionConfiguration.defaultSessionConfiguration() object. According to apple's docs, this is supposed to…
Mihado
  • 1,487
  • 3
  • 17
  • 30
1
vote
0 answers

Unexpected behaviour of URLSession while trying to get bytes uploaded

My application is continuously communicating with server and I want to calculate the bandwidth I am getting. For that I decided to calculate upload and download speed. I am using NSURLSession to communicate with my server. What I am doing is:…
1
vote
2 answers

Post Request using Nsurlsession Cache response

When i try to call post request using nsurlsession cannot able to cache the response.Please help me out. Thanks in advance
1
vote
1 answer

NSURLSessionTask creation fail in extension with backgroundSessionConfiguration

Context: I try to call a create a task (download or upload) from an action extension, with a backgroundSessionConfiguration. To do this I fallow the exemple in apple documention -(void)downloadTest { NSURLSession *mySession = [self…
Hikosei
  • 193
  • 1
  • 11
1
vote
2 answers

Downloading a file from server keeps failing, but the same obj-c code works in another environment and IOS app

IOS version is 9, Xcode 7 and following code is not working. But it works with IOS version 8, Xcode 6. I'm using codes below to download a file from server : NSURLSessionConfiguration *configuration; if ([[[UIDevice currentDevice] systemVersion]…
farzadshbfn
  • 2,710
  • 1
  • 18
  • 38
1
vote
1 answer

Changing NSURLCache memory and disk capacity doesn't work

I'm using a NSURLSession configured to use the shared NSURLCache. I'm trying to change the size of the cache when the app goes in and out of background. The idea is to reduce both memory and disk capacity when the app enters background and restore…
deadbeef
  • 5,409
  • 2
  • 17
  • 47
1
vote
1 answer

Connection retry in NSURLSession

I want to implement the connection retry in NSURLSession. Is there any parameter we need to set to achieve this like 'timeoutIntervalForRequest' and NSURLSession takes the responsibility to retry the connection. If there is no any parameter for…
1
vote
0 answers

AFHTTPSessionManager posting video swift

I am trying to upload a video in background using AFNetworking > AFHTTPSessionManager Post method. I want it to conitune uploading even if the app is suspended. But I get error while executing this code, it logs no error, and points to nowhere in…
1
vote
1 answer

NSURLRequestCachePolicy.UserProtocolCachPolicy requirements

I am using the following code for caching, the response received form the server has the following headers. Is there any header that needs to be set from the request side, for the caching to work for 10 seconds of age. Connection Received…
NNikN
  • 3,720
  • 6
  • 44
  • 86
1
vote
1 answer

NSURLSession background transfer timeout not fired

When I try to start a basic NSURLSession transfer while the network is offline (air plane mode), with NSURLSessionConfiguration defaultSessionConfiguration and ephemeralSessionConfiguration, I of course immediately receive the NSError…
1
vote
1 answer

NSURLSession ignoring NSURLSessionConfiguration Cache Policy

Even after setting the Cache Policy, my NSURLSession is still loading cached data: let url = NSURL(string: urlString); var sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration(); sessionConfig.requestCachePolicy =…
Jake Chasan
  • 6,290
  • 9
  • 44
  • 90
1
vote
1 answer

AFHTTPSessionManager block is not called when app is on background

My app get a silent push, then do some http request in background using AFNetworking,but it didn't enter the complete block, code is: AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] init]; [manager GET:urlString parameters:nil …
1
vote
1 answer

How to stop the webservice call when we move to another view

I am doing one application. In it, I did the web service part for each view. So when I moved to another view without completion of present view we service, then I need to stop the web service call in the present view. Please tell me how to do…