Questions tagged [nsurlsession]

NSURLSession is the API for HTTP connections introduced in iOS 7 and OS X 10.9.

The class NSURLSession was introduced to Apple's Foundation.framework in iOS 7 and OS X 10.9.

A NSURLSession object can be considered a group of related data transfer tasks. A response may be received and can be handled via a block statement or delegate methods. NSURLSession provides status and progress properties, of which support canceling, resuming, or suspending tasks, and resuming suspended, canceled, or failed downloads.


Types of Sessions

NSURLSession can support three different types of sessions, which is determined by the configuration object used to initialize the session object.

  • Default Sessions
  • Ephemeral Sessions
  • Background Sessions

Types of Tasks

There are three types of tasks, the last two (Download & Upload) of which support background use.

  • Data Tasks - Send and receive data via a NSData object
  • Download Tasks - Retrieves data in the form of a file
  • Upload Tasks - Sends data, most typically in the form of a file

Related tags to explore:

Adapted from Apple's URL Loading System Programming Guide > NSURLSession.

2479 questions
1
vote
2 answers

NSURLSession authentication with Rails/Devise API

I have a ROR application with an API secured by Devise + simple_token_authentication - all working fine. Now I'm building an iOS application using NSURLSession to access the API and handle authentication, which is where i get into trouble. On load…
user3108730
  • 33
  • 1
  • 5
1
vote
1 answer

NSURLSession, retry to load data

I have an NSURLSession that I use to load some data from the cloud. I use this call [[session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (!error) { NSHTTPURLResponse *httpResp =…
Eddie
  • 949
  • 1
  • 8
  • 15
1
vote
1 answer

multiple download NSURLSession

I have a program that download a video from a url using NSURLSession, but i'm not able to do multiple download at the same time. How can i do it? How can i manage multiple simultaneous download? NSURLSessionConfiguration *sessionConfig =…
1
vote
1 answer

iOS NSURLSessionDelegate [URLSession: task: didCompleteWithError:] returns with error if app is suspended

I'm writing an app that requires background downloading. I've configured my NSURLSession to be in the background Session Configuration. Everything is working when the app is in foreground or even in background mode (home button), but as soon as I…
maxf
  • 411
  • 4
  • 5
1
vote
2 answers

How to pass NSURLCredential to NSURLSession?

I'm a little confused by this. I have this method. -(BOOL)verifyAuth: (NSString*)username forPassword:(NSString*)password { NSURLSession *session = [NSURLSession sharedSession]; NSURLCredential *creds = [NSURLCredential…
Joseph Toronto
  • 1,882
  • 1
  • 15
  • 29
1
vote
1 answer

Delegate method not called after dismissing modal view controller

I am using NSURLSessionDataTask to retrieve JSON from a url in my JsonClient class, this class has a delegate protocol to notify when the json task is complete. JsonClient.h #import @protocol JsonDelegate -…
wigging
  • 8,492
  • 12
  • 75
  • 117
1
vote
1 answer

Is it possible to run code after uploading a file with NSURLSession configured as backgroundSessionConfiguration

I like to use the NSURLSession in backgroundSessionConfiguration with the method: uploadTaskWithRequest:fromFile: But I need to run some code after the upload to select the next file. When selected, I like to start the NSURLSession again to upload…
Bart Schoon
  • 299
  • 5
  • 11
1
vote
1 answer

NSURLSession remaning background time in finished download delegate

I'm using the NSURLSession background download service. If my app is suspended and in background and a NSURLSessionDownloadTask has finisehd the NSURLSessionDownloadDelegate method - (void)URLSession:(NSURLSession *)session…
derbian
  • 57
  • 1
  • 5
1
vote
1 answer

Will pending NSURLSession background download tasks start immediately after resuming app?

NSURLSession seems like a great new API. Sadly, documentation is still lacking. I am planning on supporting NSURLSession background modes. I read that, these tasks will only download on the Apple daemon if the user is connected over Wifi, and if he…
Léo Natan
  • 56,823
  • 9
  • 150
  • 195
1
vote
1 answer

Get Json response in NSURLSessionBackground for NSURLSessionDownloadTask

I am downloading images,videos with iOS 7 backgroundsession with NSURLSessionDownloadTask and it is working fine. Now,as Apple doc suggest in background DataTask is not going to work , only Uploadtask and downloadtask are going to work. So, with…
PJR
  • 13,052
  • 13
  • 64
  • 104
1
vote
1 answer

Upgrading to AFNetworking

I am taking over an old iOS project from developers no longer part of the project - the app is getting a rewrite and with that I am going to support iOS7 and upwards only. So, I wanted to use AFNetworking 2.0 instead of ASIHTTPRequest - the reason…
1
vote
1 answer

NSURLSessionConfiguration always return nil

I'm trying to access an instance of NSURLSessionConfiguration I've tried following statements to retrieve instance of NSURLSessionConfiguration. Statement 1. NSURLSessionConfiguration *aConfig = [NSURLSessionConfiguration…
sagarkothari
  • 24,520
  • 50
  • 165
  • 235
1
vote
1 answer

Prevent classes from compiling on specific iOS version

I have a class that is using NSURLSession and I still need to support iOS 6. When I try to compile targeting iOS 6, it fails, since NSURLSession doesn't exist. How do i disable this class from compiling for iOS 6?
Tony
  • 656
  • 8
  • 20
0
votes
1 answer

How to use URLSession to decide ignoreSSL from another class?

Here I have RCTHTTPRequestHandler+ignoreSSL.m that can ignoreSSL based on value from plist.info. It works nicely when I set the value of ignoreSSL from plist.info. #import "React/RCTBridgeModule.h" #import…
0
votes
0 answers

Objective C POST call not executing NSURLSession

I would like to call a POST url and pass JSON data. For some reason my NSURLSessionDataTask is not firing at all I believe. I do not see any issues with my JSON data and api url is working fine (tested with postman). Could someone please let me…
Vic85
  • 73
  • 9