Skip to main content
How are we doing? Please help us improve Stack Overflow. Take our short survey
Filter by
Sorted by
Tagged with
1 vote
0 answers
71 views

Apple's URLSession vs Cronet to support HTTP/3 using QUIC protocols in Swift iOS App

I want to implement my API's hitting mechanism to use HTTP2/3 using QUIC as their transport layer, which provides benefits for reduce latency and improved multiplexing. I am using Cronet in android ...
Sajid Zeb's user avatar
  • 1,950
-1 votes
1 answer
77 views

Do you need weak self in the closure of a data task?

Say you have extension APISingleton { func items ( _ blah: Blah?, completionOnMain: ( (_ status: Int, _ found: Blahs) -> ())? = nil ) { let t = URLSession.shared....
Fattie's user avatar
  • 13.2k
0 votes
1 answer
40 views

How to append header to URLSessionWebSocketTask

I need to append headers to URLSessionWebSocketTask, I did it using URLRequest but don't know if its proper way to do it because I use WSS connection instead of HTTP. var webSocketTask: ...
ex4mpl3's user avatar
-1 votes
1 answer
78 views

Previously working URL Session code no longer works in Xcode 15

This code has worked fine for the past couple of years, but after dusting off an old project it no longer works in Xcode 15. I have the 'URLSessionDelegate' correctly set and below is a simplified ...
Plasma's user avatar
  • 2,850
0 votes
2 answers
69 views

Incorrect URL Formation for API Request with Multi-Word Artist Names

I am working on an iOS application in Swift that fetches song lyrics using this API https://lyricsovh.docs.apiary.io/#reference/0/lyrics-of-a-song/search?console=1. However, I am facing an issue ...
paul oyebanjo's user avatar
0 votes
0 answers
73 views

Synchronous URL loading of IMAGE_LINK should not occur on this application's main thread as it may lead to UI unresponsiveness

i'm trying to get the dimensions of the image from it's URL. i wanted to use this piece of code and modify it according to my needs. here's what the final code looks like: func imageDimensions(url:...
lex's user avatar
  • 163
0 votes
1 answer
59 views

Swift: SSL Error when the function didReceive challenge function is not called

Hi I am working on the test project for fixing SSL error. When I try to get data from https://1tamilmv.eu I am getting error NSLocalizedDescription=An SSL error has occurred and a secure connection ...
Vin's user avatar
  • 57
1 vote
1 answer
110 views

URLSessionTaskDelegate authentication challenge function not being called

I'm trying to connect to a smart switch using URLSession. The switch uses http Digest Authentication which should trigger a call to delegate function urlSession(_: URLSession, task: URLSessionTask, ...
MindSpiker's user avatar
  • 1,489
-1 votes
1 answer
37 views

Who can disable the background uploading task? (Reg: BackgroundTaskCancelledReason.backgroundUpdatesDisabled)

I was working with URLSession.upload with background config. I came across this cancellation reason in URLError.BackgroundTaskCancelledReason.backgroundUpdatesDisabled Docs suggest that these are ...
Nikhileshwar's user avatar
  • 1,684
1 vote
1 answer
58 views

How can I implement retryWhen using RxSwift and URLSessionTask?

I attempted to use the retryWhen function to renew my token, but unfortunately, it threw an error: Value of type 'any Cancelable' has no member 'retryWhen' task is URLSessionTask return Observable....
Mayumi's user avatar
  • 11
0 votes
0 answers
34 views

Unable to get SSL and HTTP Protocol Types Using Alamofire

I'm using Alamofire in my project for networking. I need to extract data about the protocols used on the device from the requests, specifically the SSL encryption protocol type and the HTTP protocol ...
Eli's user avatar
  • 1
0 votes
1 answer
44 views

Method inside `URLSessionDownloadDelegate` not getting called

Here is the part of part code. The extension on ViewController has two methods. The first one getting called, but the second one not getting called once startDownload() called. // Initialising ...
sumit kumar Pradhan's user avatar
1 vote
0 answers
84 views

Trouble uploading audio files in iOS Swift using URLSession: Unexpected Behavior with Multipart Form Data

I'm encountering issues while attempting to upload audio files in my iOS Swift application using URLSession. The goal is to send an audio file along with some parameters to a server endpoint using ...
sangam pokharel's user avatar
0 votes
1 answer
120 views

URLSession implementing URLSessionDelegate to bypass any certificate verification

I have an iOS framework that is a networking module. I need to bypass certificates, but every solution I find is always based on this one, which didn't work for my situation. extension FCSession: ...
Filipe Marques's user avatar
0 votes
0 answers
27 views

Cannot convert value of type 'URLRequest' to expected argument type 'URL' from my request object [duplicate]

This is my join group function where I am trying to pass the request that is in the wrong form: do { // Assuming you have the API endpoint URL for joining a group let ...
AppleDev3's user avatar
0 votes
1 answer
143 views

URLError from rejecting a URLAuthenticationChallenge is too generic

According to this article when communicating with hardware accessories in your local network over HTTPS securely, you should be pinning your certificates like this: In the URLSessionDelegate implement ...
ph1psG's user avatar
  • 728
1 vote
0 answers
60 views

How can I send an image and a JSON together from my Swift client side to my vapor server side?

I'm currently developing the registration feature for my SwiftUI app and need to send user registration data, including a profile image selected by the user, to my Vapor server. I've heard that using ...
Miguelon's user avatar
0 votes
1 answer
96 views

Get webpage content with URLSession returns 403

I'm trying to get contents of a webpage via UrlSession, but the response status code it 403 and checking the body it seems it has a protection for robots. The strange thing is when I get the page via ...
Hadi Sharghi's user avatar
1 vote
1 answer
240 views

Weird error when trying to make a http multipart-form data request in swiftui

Here is the code for uploading a file using a POST request and form-data body type. let contentType = "multipart/form-data; boundary=\(boundary)" urlRequest.setValue(contentType, ...
sumit kumar Pradhan's user avatar
1 vote
2 answers
559 views

Disable URLSession auto retry mechanism in iOS

When i make post API call using URLSession and a network disconnection happens while the API is in progress, i receive a network error callback from URLSession - Error Domain=NSURLErrorDomain Code=-...
Nikita HN's user avatar
0 votes
0 answers
67 views

Why does my Swift DataTask completion handler never run? [duplicate]

I am trying to write a Swift Requests struct that contains methods like get, post, put, delete, etc. to make API requests in a simplified manner. Here is my requests.swift file: import Foundation ...
Daniel Crompton's user avatar
0 votes
0 answers
39 views

Trouble with Instagram API Authorization Code Exchange in Swift using URLSession

I am currently facing issues with exchanging an Instagram authorization code for an access token in my Swift application using URLSession. When I make the request using Postman, I receive the expected ...
Muhammad Bilal Raza's user avatar
0 votes
0 answers
49 views

Thread-safe API request duration calculation on iOS

I would need to calculate the duration of each API request after we receive the response. It would be easy to do: func performRequest(request: URLRequest) { let startDate = Date() let task = ...
Anastasia Veremiichyk's user avatar
0 votes
0 answers
64 views

Authorisation Missing/Droped in the Header URLSession iOS

I am experiencing some issues where the authentication header is missing on the request but when I log in Xcode it shows it is sent. When I change the header to a different name other than "...
Mzalendo's user avatar
0 votes
0 answers
59 views

SwiftUI URLSession login to ASP.net login form difficulties

Good afternoon everyone, I'm creating an IOS Application which is heavily dependant on a ASP.net website. The website is a roster site and all assignments site. Currently on my main View there is a ...
Sander's user avatar
  • 1
0 votes
0 answers
43 views

Downloading a big file with URLSession downloadTask crashes at end

I need to download a big mp4 file (>2gb) and it crashes on an iPhone mini but not on a new iPhone 15. The whole download works well and the memory is stable but when it finishes the memory spikes ...
Joan Cardona's user avatar
  • 3,651
-1 votes
1 answer
262 views

Swift: try await URLSession.shared.data(from: url) exits without throwing and without result if endpoint is down

I have a .NET core WebApi endpoint with a PING method that simply returns "PONG" when called. In a SwiftUI app (XCode 15 with iOS 17.2 target) I use this code for calling it: func ping () ...
Marcello Bassiato's user avatar
0 votes
1 answer
498 views

How to run code in the background on iOS? Not sure which methodology makes sense [closed]

I'm trying to set up background HTTP upload requests (syncing files from the user's phone to a server) that trigger periodically in my Swift app. I don't have strict requirements on when this runs (it ...
idolize's user avatar
  • 6,602
-1 votes
1 answer
392 views

URLSession - 'data(from:)' was deprecated in iOS 15.0

I'm using URLSession in concurrent context, the code I run is very simple (see below), but it's producing strange warning: // WARNING: 'data(from:)' was deprecated in iOS 15.0: Use the built-in API ...
kelin's user avatar
  • 11.7k
0 votes
1 answer
517 views

Log request and response data from URLSession

I have an iOS app that uses URLSession.shared.data in multiple places. I would like to be able to create the functionality to log the request and response data to the console. I have created functions ...
travis's user avatar
  • 55
1 vote
1 answer
78 views

What is the default value for `maximumMessageSize` in URLSessionWebSocketTask?

What is the default value for URLSessionWebSocketTask.maximumMessageSize?
Charlie Fish's user avatar
-1 votes
1 answer
84 views

Trying to figure out why my URLsession isn't working

I'm currently learning Swift and recreating an app as a project. I have this API that I'm trying to hit but it's just not working, sometimes. I put in breakpoints at the completion and sometimes I'll ...
OzosStackOverflow's user avatar
0 votes
1 answer
167 views

JSON Data not printing to the Xcode console and won´t display on one of my tab views

I am trying to decode a JSON file from a URL, but I am having issues initially. Error: Error decoding JSON: keyNotFound(CodingKeys(stringValue: "jobs", intValue: nil), Swift.DecodingError....
Steve Jobs's user avatar
0 votes
1 answer
149 views

Tracking progress for multi-file downloads using URLSessionDownloadTask(s)

I'm working on a project that requires me to track download progress for multiple files (as one). For now I've implemented this class to represent a download: class Download { var isActive: Bool ...
Leo Klaus's user avatar
  • 103
0 votes
1 answer
94 views

Sending a POST request through Swift

I am using Stripe API on the backend to process payments. Here is the API URL: http://localhost:2000/charge/new I am using SwiftUI for my iOS application to send a POST request to my API. Here is my ...
abc's user avatar
  • 1
0 votes
0 answers
84 views

How to expand a Spotify Shortened URL into Full URL?

At some point, recently (in 2023 I think), Spotify rolled out shortened links, which broke many developers' code. You can read more about it here. The shortened links seem to go through multiple ...
George Hayward's user avatar
0 votes
1 answer
134 views

iOS : Issue in accessing internet when app is launched from BGAppRefreshTask |BGProcessingTask

Use case : We want to update our app content while the app is in the background. We want to download some json data from our backend server(HTTP GET) and update the content of the application so that ...
Mohammad Yasir Perwez's user avatar
0 votes
1 answer
146 views

How to resume URLSessionDownloadTask after app termination?

I'm using URLSessionDownloadTask to download a large ZIP file in my app. However, users may close the app while the download is in progress, especially when dealing with a single large file. In my ...
KimJitae's user avatar
  • 257
1 vote
1 answer
122 views

How to use Generics with JSON Encoder in swift

I'm using JSON Placeholder post api to make a HTTP POST request using Generics and Result Type in Swift. Here is my codable struct for request and response. For this API both response and request are ...
user11640506's user avatar
0 votes
1 answer
156 views

Internal instances of `URLSession` of `URLSessionWebSocketTask` are not being released in memory

I have an issue on URLSession and URLSessionWebSocketTask that the internal instances of the classes are not released after being invalidated and canceled in both of the classes. I expected the ...
Joohae Kim's user avatar
0 votes
0 answers
71 views

Single URLSession for all requests versus per request, performance

In a legacy project which has both ObjC and Swift Code I noticed that for each request a new session was created: -(void)sendRequest { // Some configuration // New session is created for every ...
Devarshi's user avatar
  • 16.7k
-2 votes
1 answer
527 views

Is Alamofire Still Relevant in 2023? [closed]

Is there a specific reason for us to continue using the Alamofire dependency in late 2023? Given that we now have URLSession.dataTaskPublisher(for: URLRequest) and new Swift concurrency with APIs such ...
kefir's user avatar
  • 19
0 votes
0 answers
41 views

URLSessionDataTaskPublisher not handled errors properly

I have iOS application which use remote API for receiving some data (transactons) by periods. API allows make one call per 10 seconds (otherwise my IP will be blocked). Because of network issues, ...
Serhii R's user avatar
1 vote
0 answers
145 views

Twitter OAuth 2.0 working in simulator but not in real device

I am working on Twitter v2 and to get a accessToken I need to call an API. This is the API call I am doing in my swift code: let combinedCredentials = “client_id:client_Secret" guard let ...
George's user avatar
  • 3,708
0 votes
0 answers
84 views

How to structure command line app so it can make an HTTP request? [duplicate]

I'm trying to learn Swift by writing a command line app. When I run the app, unless I use dispatchMain(), I never see the HTTP response. At the same time, once the HTTP reqeust has completed, the ...
Ethan's user avatar
  • 727
0 votes
1 answer
510 views

Why did I need to set the cache policy on the URLRequest when it was already set on the URLSession to avoid caching?

I am building an iOS app that needs to frequently check for changes to a JSON file on my server. In the process of doing this I discovered a quirk with caching. My server is running a very basic http-...
CalebK's user avatar
  • 587
2 votes
1 answer
593 views

"Cannot convert return expression of type '()' to return type 'String'" compiler error when trying to access returned string from closure

func requestList(completionParameter: @escaping (String) -> String ) { let url = URL(string: "https://www.google.de")! let task = URLSession.shared.dataTask(with: url) { data, ...
Tardik's user avatar
  • 23
1 vote
0 answers
135 views

URLSessionWebSocketTask not being released after invalidate session

I have this class for handling WebSocket communication. final class SocketService: NSObject, URLSessionWebSocketDelegate { private var session: URLSession? private var socketTask: ...
rony_y's user avatar
  • 605
0 votes
1 answer
49 views

How to handle two completion handlers in one function swift

func fetch(completionHandler: @escaping ([OnSaleItem], [SlideItem], [NewArrivalItem], [EditorChoiceItem], Error?) -> Void) { apiCaller.fetchUser(completionHandler: { baseData, error in ...
Andikatama's user avatar
3 votes
0 answers
132 views

BackgroundSession FAILED to UNLINK download file when starting an uploadTask with background URLSession

I'm using a background URLSession to upload two files. The task is created via: let backgroundTask = self.session.uploadTask(with: request, fromFile: src) backgroundTask.resume() The ...
user1783732's user avatar
  • 1,823

1
2 3 4 5
17