I have a working background URLSession. I know that upon creating an URLSession with the same session identifier I get a "background URLSession with identifier x already exists" message.
I know that I can store the session and call .finishTasksAndInvalidate() on it if needed.
My use case is that if the application terminates, and the user relaunches the application before the background task completes, I need to be able to check if a background URLSession with the same identifier exists, and if it does, restitute the application state with the same handlers (so that I can update a UIProgressView for example).
I have two questions:
How do I check that a background URLSession with a given identifier already exists?
Does the AppDelegate completion handler still get called if the application was terminated and relaunched?
Post not yet marked as solved
I am deliberately using host-based virtual network to analyze potentially malicious binary, thus internet access is switched off. The cause is likely related to a previous post https://developer.apple.com/forums/thread/111225. Suggested workaround to return 127.0.0.1 from my local resolver did not help.
The setup I got is I am using local DNS resolver to answer all domain queries. Domains that binary is using to connect to are dummy-resolving fine. Browsing to these using curl/Chrome works fine. It resolves into my webserver instance which returns desired response.
However, when I execute binary itself, it fails with kCFErrorDomainCFNetwork
CFNETWORK_DIAGNOSTICS is below:
Filtering the log data using "process == "Installer" AND composedMessage CONTAINS "CFNetwork""
Timestamp Thread Type Activity PID TTL
2021-08-12 01:33:01.138319-0700 0x15b2 Default 0x0 622 0 Installer: (CFNetwork) [com.apple.CFNetwork:Diagnostics] CFNetwork Diagnostics [3:1] 01:33:01.138 {
Begin Connect to cookied: (null)
Requested version: 131075
Storage Identifier: com.apple.CFNetwork.defaultStorageSession
Persistent Storage: 1
} [3:1]
2021-08-12 01:33:01.138393-0700 0x15b2 Default 0x0 622 0 Installer: (CFNetwork) [com.apple.CFNetwork:Diagnostics] CFNetwork Diagnostics [3:2] 01:33:01.138 {
End Connect to cookied: (null)
} [3:2]
2021-08-12 01:33:01.139762-0700 0x15b2 Debug 0x0 622 0 Installer: (CoreFoundation) [com.apple.defaults:User Defaults] found no value for key com.apple.CFNetwork.HSTS.DisableHSTS in CFPrefsPlistSource<0x7ff88bc0b180> (Domain: kCFPreferencesAnyApplication, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No)
2021-08-12 01:33:01.148614-0700 0x15b2 Default 0x0 622 0 Installer: (CFNetwork) [com.apple.CFNetwork:Diagnostics] CFNetwork Diagnostics [3:3] 01:33:01.148 {
LoaderWhatToDo: (null)
Request: <CFURL 0x7ff88bdd0c30 [0x7fff9017bcf0]>{string = http://domain.com/visit/meta?mid=8F492677C538BD911DC679D49156AEA5, encoding = 134217984, base = (null)}
CachePolicy: 0
WhatToDo: originload
CreateToNow: 0.02488s
} [3:3]
2021-08-12 01:33:01.149346-0700 0x15b2 Default 0x0 622 0 Installer: (CFNetwork) [com.apple.CFNetwork:Diagnostics] CFNetwork Diagnostics [3:4] 01:33:01.149 {
AddCookies Continue: request PUT http://domain.com/visit/meta?mid=8F492677C538BD911DC679D49156AEA5 HTTP/1.1
HTTPProtocol: Task: 8bd51a70
} [3:4]
2021-08-12 01:33:01.149831-0700 0x15b2 Default 0x0 622 0 Installer: (CFNetwork) [com.apple.CFNetwork:Diagnostics] CFNetwork Diagnostics [3:5] 01:33:01.149 {
Begin Connect to cookied: (null)
Requested version: 131075
Storage Identifier: com.some.Installer
Persistent Storage: 1
} [3:5]
2021-08-12 01:33:01.149949-0700 0x15b2 Default 0x0 622 0 Installer: (CFNetwork) [com.apple.CFNetwork:Diagnostics] CFNetwork Diagnostics [3:6] 01:33:01.149 {
End Connect to cookied: (null)
} [3:6]
2021-08-12 01:33:01.151203-0700 0x15b2 Default 0x0 622 0 Installer: (CFNetwork) [com.apple.CFNetwork:Diagnostics] CFNetwork Diagnostics [3:7] 01:33:01.151 {
HTTPCookieStorage::copyCookiesForURL: <CFHTTPCookieStorage 0x7ff88bd8e5a0 [0x7ff88bd8e5b0]>
Request URL: http://domain.com/visit/meta?mid=8F492677C538BD911DC679D49156AEA5
MainDocument URL: NONE
} [3:7]
2021-08-12 01:33:01.151384-0700 0x15b2 Default 0x0 622 0 Installer: (CFNetwork) [com.apple.CFNetwork:Diagnostics] CFNetwork Diagnostics [3:8] 01:33:01.151 {
Protocol Enqueue: request PUT http://domain.com/visit/meta?mid=8F492677C538BD911DC679D49156AEA5 HTTP/1.1
Request: <NSMutableURLRequest: 0x7ff88bd7ca60> { URL: http://domain.com/visit/meta?mid=8F492677C538BD911DC679D49156AEA5 }
Message: PUT http://domain.com/visit/meta?mid=8F492677C538BD911DC679D49156AEA5 HTTP/1.1
User-Agent: Installer (Macintosh; Mac OS X 10.15.7
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
} [3:8]
Is there an option to get around this? I would not want to enable internet for obvious reasons.
Post not yet marked as solved
I am getting dozens of crash reports for our app running on iOS 14. The crash log (please see attached) indicates the crash on Thread 0. I am not able to reproduce the crash.
CrashLog
Hi Eskimo,
Hope you are doing well!!
I had implemented similar approach mentioned in [https://developer.apple.com/forums/thread/77694] in one of my projects works perfectly fine in mobile application. However, found that the same fails in watchOS .
When try to hit server from watchOS wearable app following error is displayed.
CredStore - copyIdentPrefs - Error copying Identity cred. Error=-25300, query={
class = idnt;
labl = "https://customeendpointurl:443/";
"r_Ref" = 1;
}
When I made following change in the project,
[configuration.urlCredentialStorage = nil ]
I can see no error.However, api's didn't hit server though.
Thanks in advance.
Post not yet marked as solved
Hi!
In the past few weeks we detected over 90 affected users with the following crush log:
std::__1::__shared_weak_count::lock()
CFNetwork
HTTPConnection::_onqueue_doNotAllowMoreRequests()
CFNetwork
HTTPConnectionCacheEntry::ConnectionArray::stopAndRemove(long)
CFNetwork
HTTPConnectionCacheEntry::_removeConnection(std::__1::shared_ptr<HTTPConnection>)
CFNetwork
HTTPConnectionCacheEntry::purgeIdleConnections(double, double)
CFNetwork
HTTPConnectionCache::performIdleSweep()
Unfortunately, our investigation haven't given any results. Did anyone experienced such crushes?
Top iOS versions for the crush:
12.5.4 30%
14.4.2 14%
12.5.3 6%
Hello, my app crashed on iOS 12.x, it only crashed on iOS 12.x system, I don’t know what to do?
I use NSURLSession to download remote image.
Please help me thanks
I have tried to look out and explore but can't find the reason or nor reproduce it yet.
Date/Time: 2021-08-10 04:28:44.855 +0800
OS Version: iOS 12.4 (16G77)
Report Version: 104
Monitor Type: Unix Signal
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000 at 0x0000000190b530dc
Crashed Thread: 40
Pthread id: 1160889
Thread 0:
0 libsystem_kernel.dylib mach_msg_trap + 8
1 libsystem_kernel.dylib mach_msg + 72
2 CoreFoundation __CFRunLoopServiceMachPort + 236
3 CoreFoundation __CFRunLoopRun + 1360
4 CoreFoundation CFRunLoopRunSpecific + 436
5 GraphicsServices GSEventRunModal + 104
6 UIKitCore UIApplicationMain + 212
7 MyAPP main + 300
8 libdyld.dylib start + 4
Pthread id: 1166811
Thread 40 Crashed:
0 libsystem_kernel.dylib __pthread_kill + 8
1 libsystem_pthread.dylib pthread_kill$VARIANT$armv81 + 296
2 libsystem_c.dylib abort + 140
3 libsystem_c.dylib __assert_rtn + 312
4 CFNetwork invocation function for block in TCPIOConnection::_tlsValidateServerTrust(nw_tls_context*) + 0
5 CFNetwork TCPIOConnection::_handleConnectionEvent(unsigned int, void const*) + 980
6 CFNetwork invocation function for block in TCPIOConnection::_startConnection() + 108
7 libnetwork.dylib __tcp_connection_start_block_invoke + 1020
8 libdispatch.dylib _dispatch_client_callout + 16
9 libdispatch.dylib _dispatch_block_invoke_direct$VARIANT$armv81 + 216
10 MyAPP __innerBlockOnce_block_invoke + 148
11 libdispatch.dylib _dispatch_call_block_and_release + 24
12 libdispatch.dylib _dispatch_client_callout + 16
13 libdispatch.dylib _dispatch_lane_serial_drain$VARIANT$armv81 + 548
14 libdispatch.dylib _dispatch_lane_invoke$VARIANT$armv81 + 464
15 libdispatch.dylib _dispatch_workloop_invoke$VARIANT$armv81 + 1900
16 libdispatch.dylib _dispatch_workloop_worker_thread + 584
17 libsystem_pthread.dylib _pthread_wqthread + 304
Enqueue thread backtrace:
0 MyAPP innerBlockOnce + 36
1 MyAPP _dispatch_async + 44
2 libnetwork.dylib nw_connection_report_state_with_handler_locked + 1196
3 libnetwork.dylib nw_connection_endpoint_report + 7392
4 libnetwork.dylib nw_endpoint_handler_report + 180
5 libnetwork.dylib nw_endpoint_resolver_update + 8220
6 libnetwork.dylib __nw_resolver_update_client_block_invoke + 104
7 MyAPP __innerBlockOnce_block_invoke + 148
8 libdispatch.dylib _dispatch_call_block_and_release + 24
9 libdispatch.dylib _dispatch_client_callout + 16
10 libdispatch.dylib _dispatch_workloop_invoke$VARIANT$armv81 + 2200
11 libdispatch.dylib _dispatch_workloop_worker_thread + 584
12 libsystem_pthread.dylib _pthread_wqthread + 304
13 libsystem_pthread.dylib start_wqthread + 4
Enqueue thread backtrace:
0 MyAPP innerBlockOnce + 36
1 MyAPP _dispatch_async + 44
2 libnetwork.dylib nw_queue_context_async + 88
3 libnetwork.dylib nw_resolver_update_client + 316
4 libnetwork.dylib nw_resolver_update_status_locked + 632
5 libnetwork.dylib nw_resolver_host_resolve_callback + 2472
6 libsystem_dnssd.dylib handle_addrinfo_response + 412
7 libsystem_dnssd.dylib DNSServiceProcessResult + 596
8 MyAPP __innerBlock_block_invoke + 140
9 libdispatch.dylib _dispatch_client_callout + 16
10 libdispatch.dylib _dispatch_continuation_pop$VARIANT$armv81 + 404
11 libdispatch.dylib _dispatch_source_invoke$VARIANT$armv81 + 1232
12 libdispatch.dylib _dispatch_workloop_invoke$VARIANT$armv81 + 1900
13 libdispatch.dylib _dispatch_workloop_worker_thread + 584
14 libsystem_pthread.dylib _pthread_wqthread + 304
15 libsystem_pthread.dylib start_wqthread + 4
Enqueue thread backtrace:
0 MyAPP innerBlock + 36
1 MyAPP _dispatch_source_set_event_handler + 44
2 libsystem_dnssd.dylib DNSServiceSetDispatchQueue + 236
3 libnetwork.dylib nw_resolver_create_dns_service_locked + 1836
4 libnetwork.dylib __nw_resolver_set_update_handler_block_invoke + 96
5 libnetwork.dylib nw_queue_context_async_if_needed + 100
6 libnetwork.dylib nw_resolver_set_update_handler + 328
7 libnetwork.dylib -[NWConcrete_nw_endpoint_resolver startWithHandler:] + 1696
8 libnetwork.dylib nw_endpoint_handler_path_change + 11544
9 libnetwork.dylib __nw_endpoint_handler_initialize_association_block_invoke + 172
10 libnetwork.dylib __nw_association_update_paths_block_invoke.73 + 64
11 libnetwork.dylib nw_hash_table_apply + 316
12 libnetwork.dylib nw_association_update_paths + 320
13 libnetwork.dylib nw_path_necp_update_evaluator + 1224
14 libnetwork.dylib nw_path_necp_check_for_updates + 908
15 libdispatch.dylib _dispatch_client_callout + 16
16 libdispatch.dylib _dispatch_continuation_pop$VARIANT$armv81 + 404
17 libdispatch.dylib _dispatch_source_invoke$VARIANT$armv81 + 1232
18 libdispatch.dylib _dispatch_workloop_invoke$VARIANT$armv81 + 1900
19 libdispatch.dylib _dispatch_workloop_worker_thread + 584
20 libsystem_pthread.dylib _pthread_wqthread + 304
21 libsystem_pthread.dylib start_wqthread + 4
URLSession starts waiting for connectivity when network is available, but requested domain doesn't not exist.
Some errors can shows up console:
[connection] nw_socket_handle_socket_event [C5.1:3] Socket SO_ERROR [61: Connection refused]
[connection] nw_socket_handle_socket_event [C6.1:2] Socket SO_ERROR [51: Network is unreachable]
URLSession setup:
private let config: URLSessionConfiguration = {
let config = URLSessionConfiguration.default
config.waitsForConnectivity = true
return config
}()
private lazy var session = URLSession(configuration: config, delegate: self, delegateQueue: nil)
Task:
let request = URLRequest(url: url)
let task = session.dataTask(with: request, completionHandler: { (data, response, error) in
...
task.resume()
Post not yet marked as solved
Hello everyone!
I am working on an app with quite a lot of users (100000+) and for the last year very small number of them experience an error that we were never able to reproduce.
On one of the screens we are sending POST request and it seems that for around 0.1% of users this request is 200 on a server but when they receive the response, our logs show that there is an issue with parsing.
There is a workaround that we have found though - if user resets network settings on the device, they are able to successfully receive the response and proceed with the app flow.
QUESTION:
Has anyone had an issue related to Networking that was fixed by resetting network settings on an iPhone? What could Network Reset fix that the issue is gone afterwards?
This issue happens on last several versions of iOS. We are using URLSession for network layer.
Any input will be highly appreciated, thank you very much and have a nice day :)
Post not yet marked as solved
I am trying to download app content from a password protected directory of a website served by Apache24.
The directory is protected using the following configuration segment:
<Directory "<directory path">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile <password file path>.htpasswd
Require valid-user
</Directory>
Here is my swift code (running on latest betas of iOS15 or macOS12)
class Downloader: NSObject {
lazy var downloadSession: URLSession = {
// Setup configuration
let configuration = URLSessionConfiguration.default
configuration.allowsCellularAccess = true
configuration.timeoutIntervalForResource = 60
configuration.waitsForConnectivity = true
// Add authorisation header to handle credentials
let user = "*****"
let password = "******"
let userPasswordData = "\(user):\(password)".data(using: .utf8)
let base64EncodedCredential = userPasswordData!.base64EncodedString(options: Data.Base64EncodingOptions.init(rawValue: 0))
let authString = "Basic \(base64EncodedCredential)"
// Add authorisation header to configuration
//configuration.httpAdditionalHeaders = ["Authorization" : authString]
return URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
}()
// Download file using async/await
func downloadAsync(subpath: String) async throws {
let request = URLRequest(url: URL(string: "https://<server>/")!)
let (data, response) = try await downloadSession.data(for: request)
guard (response as? HTTPURLResponse)?.statusCode == 200 else { throw HTTPError.withIdentifier((response as! HTTPURLResponse).statusCode) }
print(String(data: data, encoding: .utf8))
}
}
let downloader = Downloader()
Task.init {
do {
try await downloader.downloadAsync(subpath: "<filename>")
} catch {
print("Unable to download file")
}
}
As expected, if I run the code as is (with the authorisation header commented out) it does not download the file
As expected, if I then uncomment the authorisation line, and run it again, it DOES download the file
Here is the unexpected part (to me!):
If I re-comment out the authorisation line, and run it again it STILL downloads the file
This can be repeated for several minutes, before it finally refuses to download the file
The issue occurs on both iOS and macOS
There is a clear gap in my understanding here about what is going on, so my questions are:
What is causing this behaviour? A session cookie on the client, or something on the server?
Does it represented a security risk? (Could another client without credentials download the file shortly after a legitimate download)
If the answer to 2 is YES, how do I stop it?
Many thanks,
Bill Aylward
Post not yet marked as solved
Hello,
I am learning to use Swift and am trying to request data from the USDA Food Data Central REST API. The problem I am having is that when I try to parse the response, the 'data' object can't be read. It's not nil (tested for that) and using .count, it seems like there is data there (27531 bytes). I just can't get it to pass through the "let data = data" command.
I format the request and send it off to the API without problems, and I can read the 'response' object (there is not an 'error' object). And if I print the URLRequest.description and copy and paste it into Safari, I get a page of JSON content back (so I know the request is formatted correctly and works with the API.) I also know form the response code (200) that the API says it is successfully sending.
I also found that the response says the data is encoded in gzip. I set the "Accept-Encoding" to "identity", but that didn't solve the problem.
Any idea why this might be happening? I have been working on this for 3 days now and am hoping someone can help me figure it out.
The code is shown below (sorry for the ugly listing, I have never posted here before and can't figure out how to paste in a well-formatted code sample from Xcode...):
let API_Key: String = "48oWHEcKXeCZuuh9SGqHfhn8ttL3HcWjTDZn4gmo"
let fdcFoodItemSearchKeywords: String = "apple%20fuji"
let fdcResourceString = "https://api.nal.usda.gov/fdc/v1/foods/search?api_key=\(API_Key)&query=\(fdcFoodItemSearchKeywords)&dataType=Foundation"
guard let fdcResourceURL = URL(string: fdcResourceString) else {
print("Invalid URL")
return
}
var request = URLRequest(url: fdcResourceURL)
request.addValue("application/json", forHTTPHeaderField: "Accept")
// request.addValue("identity", forHTTPHeaderField: "Accept-Encoding")
request.httpMethod = "GET"
print("The request variable = \(request.description)")
print("The request variable http Header is: \(String(describing: request.allHTTPHeaderFields))")
URLSession.shared.dataTask(with: request) { data, response, error in
print("The data has \(String(describing: data?.count)) bytes and is: \n")
debugPrint(data ?? "Can't print data")
print("The response is: \n")
debugPrint(response ?? "Can't print response")
if let data = data {
if let decodedResponse = try? JSONDecoder().decode(FDCResponse.self, from: data) {
DispatchQueue.main.async {
self.FDCResults = decodedResponse.FDCResults
}
return
}
}
print("FDC Data Fetch Failed: \(error?.localizedDescription ?? "Unknown error")")
print(fdcResourceURL.description)
}.resume()
Post not yet marked as solved
Hello, I am very beginner at Swift and I am trying to make NSURLSession with a watch extension. The communication works fine when the watch is paired with an iPhone via wifi. However, once the connection between the phone and watch is interrupted. The watch stops sending data to the server even when it is still connected to the wifi. I would like to make the watch independent in sending the data without pairing it to an iPhone. is it possible to do it and how?
Post not yet marked as solved
I am slowly distributing my app to Beta testers via TestFlight. A few of them have already reported that the app showed “No Internet connection” while on WiFi. As soon as they switched to cellular everything started to work. But the WiFi worked for them for everything else.
One of the testers installed the app today for the first time. Still no Internet connection after switching back to WiFi from cellular.
I use Alamofire as a framework to make HTTPRequests and when these requests fail, “No Internet connection” error is displayed.
My backend service is hosted on Google Cloud, my domain is registered using AWS Route 53. I use SSL certificates managed by Google.
All HTTPRequests are sent to https://api.myapp.com (where myapp.com is hosted on AWS).
All of the testers have Automatic DNS resolution set in Settings -> WiFi -> (i) -> DNS
So far it occurred on iPhone XR and iPhone 12.
iOS versions 14.X
Any ideas how I can further investigate this issue?
Thanks
Post not yet marked as solved
App crash while using cellular network with low signal points calling NSURLSession ?
here I have attached TestFlight crash log .
crashlog.crash
Hi Apple developers,
I am new to IOS development and have recently added to my app the ability to download a file from a web API I created to be used in the app. The strange thing is this works fine in the simulator but when I plug in my IOS device I get these two errors:
nw_endpoint_handler_set_adaptive_read_handler [C2 192.168.1.67:5000 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for read_timeout failed
and
nw_endpoint_handler_set_adaptive_write_handler [C2 192.168.1.67:5000 ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, dns)] unregister notification for write_timeout failed
Other endpoints from the web API that do not involve file downloads still work on the device.
The file type is a usdz model
Here is the code used to download and store the file:
class ModelFetcher: NSObject{
var modelUrl: URL?
func generateModel() {
guard let url = URL(string: "http://192.168.1.67:5000/model.usdz") else {return}
let urlSession = URLSession(configuration: .default, delegate: self, delegateQueue: OperationQueue())
var request = URLRequest(url: url)
request.httpMethod = "POST"
let downloadTask = urlSession.downloadTask(with: request)
downloadTask.resume()
}
}
extension ModelFetcher: URLSessionDownloadDelegate {
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
print("File Downloaded Location- ", location)
let docsPath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let destinationPath = docsPath.appendingPathComponent("model.usdz")
try? FileManager.default.removeItem(at: destinationPath)
do {
try FileManager.default.copyItem(at: location, to: destinationPath)
self.modelUrl = destinationPath
print("File moved to: \(modelUrl!)")
} catch let error {
print("Copy Error: \(error.localizedDescription)")
}
}
}
Perhaps I have missed some configuration setting needed to allow file downloads on a device? Because, again, it works on the simulator but not on my own device, and, again, the other plain JSON endpoints still work on the device.
Any help would be much appreciated.
Thanks
Louis
Post not yet marked as solved
Here is the code that handles the FTP upload:
let finalRemoteName = self.fileName + ".jpg"
let dispatch = DispatchQueue(label: "Uploader", qos : .background)
let ftp = FTPAccess.init(baseUrl: FTP_URL, userName: FTP_USERNAME, password: FTP_PW, remotePath: "")
dispatch.async {
guard let ftpStream = ftp.ftpWriteStream(forFileName:
finalRemoteName)
else {
self.errorMessage = "Failed to create FTPStream"
self.result = .Error
self.resultMessage = "Failed"
return
}
if CFWriteStreamOpen(ftpStream) == false {
self.errorMessage = "Could not open FTPStream"
self.resultMessage = "Failed"
self.result = .Error
}
let fileSize = self.data.count
let buffer = UnsafeMutablePointer&lt;UInt8&gt;.allocate(capacity: fileSize)
self.data.copyBytes(to: buffer, count: fileSize)
defer {
CFWriteStreamClose(ftpStream)
buffer.deallocate(capacity: fileSize)}
var offset: Int = 0
var dataToSendSize: Int = fileSize
repeat {
DispatchQueue.main.async {
self.progress = 1.0 -
Float(dataToSendSize) / Float(fileSize)
}
let bytesWritten = CFWriteStreamWrite(ftpStream,
&amp;buffer[offset], dataToSendSize)
if (bytesWritten &gt; 0) {
offset += bytesWritten.littleEndian
dataToSendSize -= bytesWritten
continue
}
else if (bytesWritten &lt; 0) {
self.errorMessage = "FTP Upload Error"
self.resultMessage = "Failed"
self.result = .Error
return
}
else if (bytesWritten == 0) {
print("Finished Upload")
DispatchQueue.main.sync {
self.resultMessage = "Success"
self.result = .Success
}
return
}
}. while (true) }.
return self.result
}
}
}`
Again, this works perfectly on the simulator, all versions, and for older iPhone models. On newer iPhone models the upload simply isn't working and I'm not sure why.
Here are my questions?
How would you go about capturing the error message IF there is an error message being captured because it's not causing a crash that would show up in TestFlight?
Could this possibly be a case of the info file being incorrect for an app that communicates with an external FTP server? If so, why does it work for older phones but not newer ones and what is the solution?
Another problem I'm facing is that the upload speed is terribly slow. It's not like this on the Android version of the app so I know it's not an issue with the server itself. Do you see anything in here that would possibly limit the chunk size of the uploaded image possibly? Is there another reason I'm missing?
Post not yet marked as solved
I want to access twitter filter search v2 endpoint https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/integrate/recovery-and-redundancy-features in ios app can you tell me how can I access the stream. the normal api call does not seems to work. However the python sample code https://github.com/twitterdev/Twitter-API-v2-sample-code/blob/main/Filtered-Stream/filtered_stream.py seems to work but I am unable to achieve it in ios. Can you guide me towards an example that involves embedding python or ruby code inside ios app?
Post not yet marked as solved
i am having problem while using NSStream api for SSL Connection, i am getting 9806 error whenever i connect to SSL Server i am using valid p12 file. Please let me know what could be the problem?.
NSString *path = [[NSBundle mainBundle] pathForResource:@"client" ofType:@"p12"];
NSData *certData = [[NSData alloc] initWithContentsOfFile:path];
NSString*host = @"some host ip";
CFStreamCreatePairWithSocketToHost(NULL,
(__bridge CFStringRef)host, 12345,
&readStream, &writeStream);
CFArrayRef keyref = NULL;
OSStatus sanityChesk = SecPKCS12Import((__bridge CFDataRef)certData,
(__bridge CFDictionaryRef)[NSDictionary
dictionaryWithObject:@"123456"
forKey:(__bridge id)kSecImportExportPassphrase],
&keyref);
if (sanityChesk != noErr) {
NSLog(@"Error while importing pkcs12 [%d]", (int)sanityChesk);
}
else
NSLog(@"Success opening p12 certificate.");
CFDictionaryRef identityDict= CFArrayGetValueAtIndex(keyref, 0);
SecIdentityRef identityRef = (SecIdentityRef)CFDictionaryGetValue(identityDict,
kSecImportItemIdentity);
SecCertificateRef cert = NULL;
OSStatus status = SecIdentityCopyCertificate(identityRef, &cert);
if (status)
NSLog(@"SecIdentityCopyCertificate failed.");
NSArray *myCerts = [[NSArray alloc] initWithObjects:(__bridge id)identityRef, (__bridge id)cert, nil];
NSMutableDictionary *settings =[[NSMutableDictionary alloc]init];
[settings setObject:(NSString *)NSStreamSocketSecurityLevelNegotiatedSSL forKey:(NSString *)kCFStreamSSLLevel];
[settings setObject:[NSNumber numberWithBool:NO] forKey:(NSString *)kCFStreamSSLIsServer];
[settings setObject:[NSNumber numberWithBool:NO] forKey:(NSString *)kCFStreamSSLValidatesCertificateChain];
[settings setObject:(NSString *)NSStreamSocketSecurityLevelNegotiatedSSL forKey:(NSString *)kCFStreamSSLLevel];
[settings setObject:myCerts forKey:(NSString *)kCFStreamSSLCertificates];
[settings setObject:@"some host ip :12345" forKey:(NSString *)kCFStreamSSLPeerName];
CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket,
kCFBooleanTrue);
CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket,
kCFBooleanTrue);
CFReadStreamSetProperty((CFReadStreamRef)readStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
CFWriteStreamSetProperty((CFWriteStreamRef)writeStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
NSInputStream * inputStream = (__bridge_transfer NSInputStream*)readStream;
inputStream.delegate = self;
NSOutputStream * outputStream = (__bridge_transfer NSOutputStream*)writeStream;
outputStream.delegate = self;
[inputStream setProperty:NSStreamSocketSecurityLevelNegotiatedSSL forKey:NSStreamSocketSecurityLevelKey];
[outputStream setProperty:NSStreamSocketSecurityLevelNegotiatedSSL forKey:NSStreamSocketSecurityLevelKey];
CFReadStreamSetProperty((CFReadStreamRef)inputStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
CFWriteStreamSetProperty((CFWriteStreamRef)outputStream, kCFStreamPropertySSLSettings, (CFTypeRef)settings);
[inputStream setProperty: settings forKey: (NSString *)kCFStreamPropertySSLSettings];
[outputStream setProperty: settings forKey: (NSString *)kCFStreamPropertySSLSettings];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream open];
[inputStream open];
There are two delegate methods used to process ssl challenge.
The session level
(URLSession:didReceiveChallenge:completionHandler:)
and the session task level
(URLSession:task:didReceiveChallenge:completionHandler:)
If we used URLSession with background configuration to start a uploadTask, the session level didReceiveChallenge() will be called on iOS 13 and 14. (or earlier)
(uploadTask(with:fromFile:))
But on iOS 15, it's the session task level didReceiveChallenge() delegate method be called.
I wonder why the behavior had changed on iOS 15?
Thanks for reply!
Post not yet marked as solved
Hello, our app uses a REST API with certificate based authentication to retrieve data about logged in users and it is not working anymore since the iOS 15 update (but it works on previous iOS versions) on real devices or simulators. The error we're getting is 403. Any help would be greatly appreciated.
Post not yet marked as solved
Hello,
I am trying to write an iOS app which could receive and analyze mDNS queries.
More specifically, I have my app register a Bonjour service, and I need to see queries from the network for any subtype of my primary type, although I have not registered any subtype myself.
Reason being that I have a device that tries to find me using a specific primary type, but always includes a subtype in its queries, and I can't know the subtype in advance, so I can't register my service with the subtype. So I'd need to see the query, extract the subtype and re-register my service with that subtype so that the device can then find me.
Looks like the various APIs to interact with Bonjour won't let me do that.
I've tried another approach and started a NWListener on port 5353 with allowLocalEndpointReuse set to true, but I'm getting "Address already in use" and it doesn't work, since this port is likely to be used by the mDNSresponder service.
Is there an API I could use to achieve what I described above ?