Questions tagged [nsurlsessiondatatask]

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

265 questions
2
votes
2 answers

How do I implement background fetch using a data task?

I'm trying to implement background fetch in an iOS app. In the official documentation is stated: "You don’t have to do all background network activity with background sessions ... ... . Apps that declare appropriate background modes can use default…
Daniele Cux
  • 348
  • 2
  • 12
2
votes
1 answer

Swift background data task

I'm trying to make a background post request in Swift. I know that I should configure a background URLSession and use a delegate instead of a completion handler. Here's the delegate I'm using: class Delegate:NSObject, URLSessionDelegate,…
Vahid
  • 1,829
  • 1
  • 20
  • 35
2
votes
1 answer

Is keeping a reference to an URLSessionTask necessary?

I've reading several examples related to URLSession and URLSessionTask where code snippets were shown and/or the sample project was available to download. Examples were about the quite common scenario of requesting some info to a REST service by…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
2
votes
2 answers

Objective-C create mapped file for PDF

I am creating a file like so: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; filePath = [NSString stringWithFormat:@"%@/%@",…
user979331
  • 11,039
  • 73
  • 223
  • 418
2
votes
0 answers

iOS 11 URLSessionDataTask's progress variable is not showing right progress

I need to find out progress of an upload task. But I can only use the URLSession's dataTask method (instead of uploadTask method) to create the task. I can't use delegate initializer to create the session also. To find the progress I'm using KVO on…
user1165756
  • 375
  • 3
  • 11
2
votes
1 answer

Request working properly with postman but fails with protocol error when requesting with iOS

I am trying to run this request and the reason I am doing is that from here is that I want to test push notifications (I mean a lot of them) with different strings in a loop. When I try to do it with Postman it works perfectly fine I mean I had…
user3745635
  • 847
  • 1
  • 8
  • 21
2
votes
1 answer

ios get decodable object parameter from json urlsession dataTask

From this reponse from URLSession dataTask, how do I transpose the data recieved: response: {"message":"login…
NojDavid
  • 89
  • 1
  • 10
2
votes
1 answer

iOS UrlSession.shared.dataTask removes utf-8 "+" character and replaces it with " "

I'm creating a login call to an API using x-www-form-endoded data. I created a POST in Postman and received a 200 response. I used Postman's export function to generate the OKHTTP code for Android and NSURL code for iOS. The Android code works…
James Jordan Taylor
  • 1,560
  • 3
  • 24
  • 38
2
votes
0 answers

URLSession dataTask: with URLRequest/URL? OperationQueue in completionHandler?

I want a URLSession to perform an HTTP network call and parse its JSON response. I'm following an example which more or less matches my scenario, and I found this code: let request = URLRequest(url: url) let dataTask = myUrlSession.dataTask(with:…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
2
votes
1 answer

Error with NSURLSessionDataTask in iOS 10

I am having an issue with NSURLSessionDataTask , while trying to upload a JSON object , I am getting the following message in console . [] __tcp_connection_write_eof_block_invoke Write close callback received [error: [89] Operation canceled] How…
2
votes
1 answer

Do not execute the block if task is cancelled

I have MainViewController -> ThumbnailViewController -> ImageFullScreenViewController. As their name implies, I have a main screen from which I go to a screen which shows collection of images and on selecting an image, I open the image in full…
iOS
  • 3,526
  • 3
  • 37
  • 82
2
votes
0 answers

How to Cancel NSURLSessionDataTask 'Inside' A RACSignal

I am using Reactive Cocoa to merge & collect multiple network requests together (as RACSignals) like so: [[[RACSignal merge:requestSignals] collect] subscribeNext:^(NSArray *results){...} Each individual RACSignal is created like so: - (RACSignal…
jac300
  • 5,182
  • 14
  • 54
  • 89
2
votes
1 answer

iOS: AFNetworking multiple download. Request operation timeout

I try to download a large number of files >= 500 with AFNetworking 3.0 GET-request.Total load weight is approximately equal to ~ 1.7 Gb. Currently, I use: for (NSSttring *url in urlsArray){ [self.sessionManager…
2
votes
2 answers

Synchronous fetching data NSOperationQueue or NSURLSession

In my app , we have to make 3 server calls when we click on the login button. 1) will make a server call to get an OAuth token for user credentials 2) with the token from (1) we will get user privileges 3) with the token from (1) and with the valid…
Sharanya K M
  • 1,805
  • 4
  • 23
  • 44
2
votes
0 answers

Using NSURLSessionDataTask, can I resume downloading a file, even if user comes back after quitting an App?

Suppose, I am downloading a file of 300 MB using NSURLSessionDownloadTask or NSURLSessionDataTask (at present, I don’t know which is the best choice in my case). User quits the App or App suddenly crashed while 250 MB were downloaded. When next…
1 2
3
17 18