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

Moving to a background NSURLSession from a foreground NSURLSession - Handling Tasks in Process

I am trying to correctly handle in-process NSURLSessionTasks in the event that the app enters the background (e.g from a home button press). I am currently taking the approach of copying the in-process tasks across to the background queue (see code…
2
votes
2 answers

NSURLSession background transfer : Callback for each video downloaded from a queue

I am using background transfer service for downloading multiple videos using NSURLSession. Downloading is working fine when the App is in background mode and I am satisfied with it. My problem is, I want callback for each video downloaded from a…
2
votes
0 answers

Resume upload task using NSURLSessionUploadTask after app is killed?

I am using the following code to upload image using NSURLSessionUploadTask NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AFURLSessionManager *manager = [[AFURLSessionManager alloc]…
2
votes
2 answers

Initializer does not override a designated initializer while subclassing NSURLSession Swift

I want to subclass NSURLSession class, but I have problem with initialisation. Basically I override the constructor and initialising the constant authUrl there then calling the parent init method. class NSURLAuthSession: NSURLSession { let…
Alexey
  • 7,127
  • 9
  • 57
  • 94
2
votes
1 answer

How to make a NSURLSession repeat at a certain interval?

I am interesting to make NSSession repeat itself at a certain interval without using an NSTimer object, I am looking if I can set some property of the NSURLRequest or of the NSURLSessionConfiguration that I have overlooked?
Laur Stefan
  • 1,519
  • 5
  • 23
  • 50
2
votes
1 answer

Can I update cookies in the configuration of a NSURLSession after its creation?

Can I update cookies in the configuration of a NSURLSession after the creation of the session? I use this code to update the cookies but it doesn't seem to work. self.session = [NSURLSession sessionWithConfiguration:config delegate:self…
2
votes
0 answers

NSURLSessionDownloadTask finishes with no file at the location URL

I fire a bunch of downloads using NSURLSessionDownload tasks and NSURLSession with background configuration. Most of the time everything works fine but sometimes there is no temp file at the location specified in the delegate callback method. It…
2
votes
3 answers

Is there a way to remove the delay when [NSURLSessionConfiguration backgroundSessionConfiguration] is used?

I am trying to run a background NSURLSessionDownloadTask. However, I noticed that it takes approximately 30 seconds before the task actually begins. When I use the defaultSessionConfiguration, the task starts almost immediately. Is there a way to…
jhk
  • 261
  • 3
  • 13
2
votes
1 answer

NSURLSessionConfiguration timeoutIntervalForRequest doesn't seem to work with the background session

The new timeout property of NSURLSessionConfiguration doesn't seem to work when the session is set to work in background (via backgroundSessionConfiguration call). Anybody know if that's really the case? Code snippet: NSURLSessionConfiguration…
ymotov
  • 1,449
  • 3
  • 17
  • 28
2
votes
2 answers

Multiple background downloads in ios7 using NSURLSessionConfigurations

I want to know about how to download a bunch of files one after the other. It is like if I have 5 files to download, I should automatically download all the 5 files in a sequence 1 complete then 2 , 2 then 3 this way all five should be completed…
Gupta
  • 53
  • 6
1
vote
1 answer

What happens behind when I create URLSession with background configuration?

I am trying to upload large files from iOS to a server using URLSessionConfiguration.background object and uploadTask function. Things are looking good til now, but I wonder what actually happens behind the scene when the app goes into background…
hjh5696
  • 53
  • 1
  • 7
1
vote
2 answers

Swift: URLSession extension configuration error: Cannot call value of non-function type 'URLSession'

I have this function: class myClass: ObservableObject { func doSomethingElse(url: URL, config: URLSessionConfiguration, type: T.Type) ->…
user2924482
  • 8,380
  • 23
  • 89
  • 173
1
vote
0 answers

Timeout when offline iOS (using waitsForConnectivity)

Whilst implementing several HTTP calls, I noticed some strange behaviour on the URLSession. As far as I know, URLSession data tasks used to immediately throw an error when the network connection was unavailable (error -1009 The Internet connection…
Bram
  • 2,718
  • 1
  • 22
  • 43
1
vote
0 answers

Add additional headers to Alamofire Session

Session Configuration: func createAfSession() -> Alamofire.Session { let sessionConfig = URLSessionConfiguration.af.default sessionConfig.headers.add(name: "abc", value: "ABC") return Alamofire.Session(configuration:…
Roshan Sah
  • 137
  • 10
1
vote
1 answer

Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"

I am facing weird issue while try to download file using URLSession and URLSessionConfiguration.background(withIdentifier: Bundle.main.bundleIdentifier!) While start downloading file using URLSession.downloadTask with background…