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
0
votes
1 answer

URLSessionConfiguration 'waitsForConnectivity' behaviour when the app is killed

If a URLSessionDataTask is waiting for connectivity and the app get's killed or suspended for some reason will the OS complete the task when the device connects to internet and relaunch the app in background to notify the appropriate delegate…
0
votes
0 answers

Is data coming from cache?

Requirement: Get the data from the cache if NSMutableURLRequest can not fetch data from the server.If internet available and i got the data from the server then function will return server data but if request fail to get the data from the server…
0
votes
1 answer

Authorization fails (cookes not sent) in URLSessionConfiguration.background with HTTPCookieStorage.shared

In my iOS app, I create a URLSession with default configuration: // Part #1 let urlSession = URLSession(configuration: .default) The user logs in, the cookies are set and all API requests are Authorized and work fine. Now with the same cookies,…
Raunak
  • 3,314
  • 1
  • 22
  • 28
0
votes
0 answers

Issue with RestApi with Basic Authentication

I am trying to call a RestApi call with basic authentication. I am able to make the call succesfully, but the issue that i am facing is that if i give wrong username & password in the call, then also I am getting sucess response. I tried by making…
0
votes
1 answer

Unrecognized selector when accessing properties of URLSessionConfiguration subclass

I wanted to subclass URLSessionConfiguration to set some default values for properties such as timeout intervals and httpHeaders. So I came with this custom subclass. class CustomSessionConfiguration: URLSessionConfiguration { init(time:…
0
votes
1 answer

Session Configuration Time Out interval not able to set greater than 60 seconds

In my application data that I fetch from server is quite heavy and is coming as Bulk Data in single API. Due to which I increased my Time Out Interval to 1800 seconds. My code is NSURLSessionConfiguration *sessionConfiguration =…
0
votes
0 answers

Perform a Post using URLSession and waitsForConnectivity in background

I want to post a json using URLSession when the connection is active. For that, I'm using URLSessionConfigurationand setting configuration.waitsForConnectivity = true and it works fine. my problem is when the App goes to background before the…
0
votes
0 answers

Making Network Requests in the Background on watchOS

I have a Apple Watch app that let's users record audio and they syncs it with the cloud. Once the user is done recording, I upload the file and some corresponding data. Problem is that if I use a defaultSessionConfiguration for foreground requests,…
0
votes
0 answers

How to get network change (connect or disconnect) notification when app is in background?

In my application I need to capture the network connectivity status change while connecting or disconnecting even when my app is in the background. I have implemented Reachability class. [[NSNotificationCenter defaultCenter] addObserver:self…
0
votes
1 answer

Google Maps iOS SDK with custom URLSessionConfiguration

Since iOS 11 we can set: let sessionConfiguration = URLSessionConfiguration.default sessionConfiguration.multipathServiceType = .interactive Then when WiFi connection is too slow, the app will automatically switch to cellular network, so HTTP…
Paul T.
  • 4,938
  • 7
  • 45
  • 93
0
votes
1 answer

Country Code `+` is ignored in mqsql remote database table cell

This is my server request call, where I save user info into my remote database server. + (void)sendRequestToServerForCreatingUserModel:(UserModelClass *)userModelClass { NSLog(@"userModelClass.user_country_code %@",…
Tulon
  • 4,011
  • 6
  • 36
  • 56
0
votes
0 answers

NSURLSession Background task stops while clicking the home button?

I have develop a HTTP module for making upload download request using URLSession Background sessions. The HTTP module work in Serialize mode as specified in URLSession doc by passing nil to queue. On download complete…
0
votes
3 answers

Cannot invoke 'dataTask' with an argument list of type (with: NSMutableRequest, ...)

func performGetRequest(_ targetURL: URL!, completion: @escaping (_ data: Data?, _ HTTPStatusCode: Int, _ error: NSError?) -> Void) { let request = NSMutableURLRequest(url: targetURL) request.httpMethod = "GET" let sessionConfiguration…
0
votes
3 answers

How to go back to previous screen after a timeout request?

I'm trying to set up the network session creator to go back to the previous screen if the timeout request runs out. As of now I'm not completely sure where or how to execute it. Here is the code: lazy var configuration: URLSessionConfiguration =…
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
0
votes
0 answers

How to do Client Certificate Authentication using NSURLSession with background session configuration?

My application backend requires Client Certificate authentication. If I configure NSURLSession with default configuration, didReceiveChallenge delegate gets called where I am providing valid client certificate. It successfully completes the task.…