Questions tagged [nsurlsessiondatatask]

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

265 questions
0
votes
0 answers

MacOS Ventura, async network URLs and rate limits

I recently upgraded to MacOS Ventura and discovered that software I'd written in the past to scrape data from a webpage would no longer work. That code used initWithContentsOfURL to access and download a sequence of pages which my code would then…
0
votes
1 answer

URLSessionDataTask - upload parameters with multipart/form-data content type

I would like to create body like in this curl example: curl --location --request POST 'https://request.url' \ --header 'Authorization: Bearer xxx' \ --form 'name="Name"' \ --form 'data="[{\"text\": \"This is comment\", \"another\":…
Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
0
votes
1 answer

URLSession.shared struct property isn't working for Combine API call

I have following APILoader struct in my network layer. struct APILoader { var apiHandler: T var urlSession: URLSession init(apiHandler: T, urlSession: URLSession = .shared) { self.apiHandler = apiHandler …
0
votes
0 answers

Make a Get Request api to a JWT enabled endpoint

I am trying to make a get request to a JWT enabled API but I am getting my result in bytes instead of objects after the user logs in it is expected to go the next page where it lists user projects, at the moment I've created a button which when…
Wilson Agene
  • 73
  • 1
  • 5
0
votes
0 answers

Why is this URLSession.datatask not working in Swift 5 for macos

I am trying to make my own DynamicIP updater as a command line tool so I can set it up to run as a launch agent. I thought this would be a pretty simple thing to do, but I am not getting anything when I run this bit of code. main.swift: import…
SouthernYankee65
  • 1,129
  • 10
  • 22
0
votes
0 answers

How to check if one of URLSession tasks returned an error and if so to stop code execution?

I need to make 2 API calls simultaneously. I have 2 URLs for the calls, and if one of the calls will return any error I want to stop all the code execution. How I tried to do it: I have a function called performRequest() with a completion block. I…
0
votes
0 answers

How to properly cancel and restart an URLSessionDataTask Swift

This is my request funtion: func receiptValidation(completion: @escaping(_ isPurchaseSchemeActive: Bool, _ error: Error?) -> ()) { let receiptFileURL = Bundle.main.appStoreReceiptURL guard let receiptData = try? Data(contentsOf:…
Tulon
  • 4,011
  • 6
  • 36
  • 56
0
votes
1 answer

How to parse html that has the updated DOM? Swift

I am fairly knew to coding and am parsing html data from a webiste. The problem is that the elements that I can manually inspect when I view the website are very different from the source code. I understand this is because 'inspecting elements' show…
0
votes
1 answer

Translate data task function for background upgrade from Swift to Objective C

I'm trying to implement a function in AppDelegate.m in order to update my app in background. I've found an article online (this is the link: https://medium.com/@vialyx/ios-dev-course-background-modes-fetch-70c18f9f58d5) but it's written in Swift and…
0
votes
2 answers

URLSession dataTask execution order

i am trying to fetch images data using URLSession dataTask the urls are fetched from a firebase firestore document that contains each download path using for loop in snapShotDocuments in ascending order, after that the urls are passed into the…
0
votes
1 answer

datatask not executed, request is null

import Foundation let headers = [     "x-rapidapi-key": "myKey",     "x-rapidapi-host": "movie-database-imdb-alternative.p.rapidapi.com" ] let urlR = URL(string: "https://movie-database-imdb-alternative.p.rapidapi.com/?i=tt4154796&r=json") var…
0
votes
1 answer

How to make serial queue for a few URLSession.DataTaskPublisher?

I have several datataskpublisher, which performs requests to the server, from different application screens. How to make them run serial? Below will be a rough example This is a service that performs requests and additional logic. class Service { …
0
votes
0 answers

Process a dataTask GET request on background

I have an API to get about 1000 records from a GET request. Currently I'm using dataTask to get the content via URLSession. Complication is the request just freeze as soon as it enters to the background mode. When i did some research I found out…
danu
  • 1,079
  • 5
  • 16
  • 48
0
votes
0 answers

How to control the concurrent download counts in iOS?

I have an array of video URLs that need to be downloaded. To keep the overall performance, I want to limit the concurrent download counts to 2. For example, I want to start the first two download tasks concurrently at the beginning, then start the…
P. Tsin
  • 435
  • 4
  • 14
0
votes
1 answer

Attach parameters to NSURLSession Delegate Method

I would like to pass a parameter into my delegate to determine to continue or check for cert. - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void…
Ezos
  • 107
  • 1
  • 12