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

Not sure what happens to my apps objects when using NSURLSession in background - what state is my app in?

More of a general question - I don't understand the workings of NSURLSession when using it in "background session mode". I will supply some simple contrived example code. I have a database which holds objects - such that portions of this data can be…
Avba
  • 14,822
  • 20
  • 92
  • 192
3
votes
1 answer

Issues with NSURLSession Not Sending HTTPAdditionalHeaders

I can't seem to get my networking code to work. I've spent at least a couple hours looking through documentation and Google this over the last 2 days and I can't figure it out. For whatever reason, it appears my NSURLSession isn't sending along the…
3
votes
2 answers

NSURLSession and NSDefaultRunLoopMode

When using NSURLConnection, you had the option to schedule the connection using NSRunLoop: - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode Passing NSDefaultRunLoopMode would effectively cause the connection to pause if the…
2
votes
0 answers

iOS | URLSession | Download task| didWriteData not calling when user switch between apps and come

In my application, I need to download a file(size:50mb), also I need to support background downloading. By the following code I can do the download even in the background. The only problem is UI is not updating properly when I tried to switch the…
Sridhar
  • 2,228
  • 10
  • 48
  • 79
2
votes
1 answer

NSUrlSession proxy request fails with error code 310 (kCFErrorHTTPSProxyConnectionFailure)

I'm trying to send a POST request to a specific URL through a proxy server. To test that the code I'm writing is working, I installed squidman on my machine and started a proxy server on port 33074. I tested the proxy server by changing the network…
cuv
  • 1,159
  • 2
  • 10
  • 20
2
votes
0 answers

URLSession 'Network connection is getting lost' in background state

I am using URLSession to fetch the live preview of the image from the server. But whenever I am keeping app into the background state for just second and coming back to foreground state I am getting following error message. load failed with error…
2
votes
1 answer

URLSessionConfiguration equatability across SDK versions

Given the following playground: import Foundation let config = URLSessionConfiguration.default let session = URLSession(configuration: config) let eq = config == session.configuration If you run the playground in Xcode 9.4.1, eq evaluates to…
2
votes
2 answers

Should we create the difference unique session identifier for all difference downloadable files - swift

I am newbie IOS programming. I want to create a sample app which allow user to download many files from my server. For example, I have 10 files, then should I call method let configuration = URLSessionConfiguration.background(withIdentifier:…
Visal Sambo
  • 1,270
  • 1
  • 19
  • 33
2
votes
1 answer

How to get reference of a background file-download Task in Swift?

I am successfully able to download a file in the background. Upon App closing and App-reopening, there is still data downloaded as expected. However, in order to show the UI according to data-download-state, I need a reference to the actual…
iKK
  • 6,394
  • 10
  • 58
  • 131
2
votes
1 answer

Can NSURLSession objects be created multiple times with different configurations?

Can I make a session object whenever I need with different configurations or is there any constraint on creating session objects?
jegadeesh
  • 875
  • 9
  • 22
2
votes
1 answer

NSURLSession background configuration benefits on macOS

On iOS it’s critical to init a NSURLSession with a background configuration to get the benefit of uploading and downloading while the app is background: Example in Swift 2: let configuration =…
kev
  • 7,712
  • 11
  • 30
  • 41
2
votes
2 answers

How to select specific network interface for NSURLSession connections?

I’m not talking about Reachability. What I’m talking about is figuring out how to create a network connection from an iOS device across the cellular interface. Why? Because I have conditions where the device connects to a WiFi access point so it…
2
votes
1 answer

iOS Networking - HTTP Connections & running in background

I have an app that lets the user send messages with images. A user might hit send, then immediately close their phone or switch to another app. We were running into an issue that if there's temporarily a bad network connection the message would fail…
danny
  • 10,103
  • 10
  • 50
  • 57
2
votes
0 answers

sessionWithConfiguration: delegate: delegateQueue: working in simulator but not in device

I am downloading multiple audio files using background transfer service, everything was working as expected till yesterday. Now when I run the project it stuck on the second line of following lines - NSURLSessionConfiguration *configuration =…
Devesh
  • 193
  • 1
  • 1
  • 8
2
votes
1 answer

NSURLSession error when uploading on WiFi: NSURLErrorDomain Code=-999

I built an app, more than an year ago, that provides photo sharing and video sharing for its users. It ran without any problems until a couple of weeks ago where I introduced a new feature: the possibility of marking a video to be uploaded only when…
1 2
3
9 10