Questions tagged [nsurlsessiondatatask]

See Apple documentation for Swift (URLSessionDataTask) and Objective C.

265 questions
1
vote
0 answers

Enable cross-site tracking for iOS network requests

I would like to enable cross-site tracking for one of my iOS network requests - I can't find anything on which configuration setting would provide that option. I am using a shared URLSession and for every request I create a separate…
nambatee
  • 1,478
  • 16
  • 27
1
vote
0 answers

POST request error when app goes to background

Is it expected behavior for a POST request in URLSessionDataTask to have an error NSURLErrorNetworkConnectionLost -1005 when the app goest to the background during the request? For example, during a POST web service request, the user taps the home…
SleepNot
  • 2,982
  • 10
  • 43
  • 72
1
vote
1 answer

NSUrlSession: Challenge NSURLAuthenticationMethodServerTrust fails only when client certificate is also needed

we want to connect our app to our IIS webservice. We use self signed certificates and also a client certificate for authentication. When the webservice doesn't require client certificate authentication, everything works fine,…
Tobe
  • 198
  • 2
  • 13
1
vote
1 answer

ios URLSessionDataTask use resume with Data

I'am using URLSessionDataTask to download videos and play them (I need caching so I'am using the func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) to manually handle the data and provide them to…
1
vote
0 answers

NSURLSession didReceiveData called continuously for same request with same response

- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data { } The above delegate method is called repeatedly so that the below delegate method is not called and app is hanged because of…
Ganesh Bavaskar
  • 754
  • 6
  • 15
1
vote
0 answers

URLSession dataTask doesn't work

im new at swift and im trying to get response from a soap services, but the dataTask in my session never get in, always skip it. I already test te urls and the soap message but i don't have any lucky. Here is my code func servisRun(){ let…
1
vote
1 answer

Facing an issue with NSURLSessionDataTask with SynchronousRequest in objective-c

Here is my working code with NSURLConnection sendSynchronousRequest : + (Inc*)getData:(NSString*)inUUID { NSString* urlString = [NSString stringWithFormat:@"/inc/%@", incUUID]; NSURLRequest* request = [[HttpRequest…
1
vote
3 answers

images can't be display in table view

I created a tableView with custom cells that each cell has an image. In the model class, I created a func mainPulatesData() to use URLSession dataTask method to retrieve data from url, and convert data into UIImage in the completion handler…
CEz
  • 43
  • 1
  • 7
1
vote
1 answer

still timeout after I suspend NSURLSessionDataTask in AFN3.1.0

I init NSURLSessionDataTask with follow method - (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable…
Rachel
  • 11
  • 3
1
vote
3 answers

Cookies don't exist when using URLSessionDataTask

I'm trying to access my backend API using a URLSessionDataTask. Part of this includes accessing cookies stored using Safari. For example, the php code in the backend for http://api.example.com/v1/getCookies is echo $_COOKIE["myCookieName"]; The…
Jojodmo
  • 23,357
  • 13
  • 65
  • 107
1
vote
1 answer

URLSession.shared.dataTask with body / payload

The following code is working perfectly for a simple http request. However I cant find a way of adding a payload or body string in Swift 3? and previous versions are depreciated func jsonParser(urlString: String, completionHandler: @escaping (_…
1
vote
2 answers

How to get html from url AFTER ajax on webpage has finished

I'm writing an app in Swift 3.0 and I'm trying to scrape data from the search results of a webpage. I perform the search by including the search query as a parameter in the url, but the html that's getting returned to me has no results. I believe…
jeremyabannister
  • 3,796
  • 3
  • 16
  • 25
1
vote
1 answer

How to handle the application if connection breaks in between a web service call

In several interviews I have been asked about handling of connection, web service calls, server responses and all. Even now I am not clear about many things.Could you please help me to get a better idea about the following scenarios? What is the…
1
vote
2 answers

Alert Controller Freezes on main thread

Am connecting to the services and receiving the data from backend. The code is as follows: _ = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) in if response != nil{ var responseREcvd =…
1
vote
1 answer

Problems with Swift3: cannot understand new syntax

Yesterday I updated to Xcode 8.2 which forced me to update to Swift 3.0 syntax. In my app I have this function: func performGetRequest(_ targetURL: URL!, completion:@escaping (_ data: Data?, _ HTTPStatusCode: Int, _ error: NSError?) -> Void) { …
bero
  • 13
  • 4