We have a device which is an appliance and we are developing a control interface app for macOS and iOS/iPadOS.
How can we set up our iOS application to grab information from a local network device while it is in the background in order to show notifications?
Communication between the Apple device and our device is via local networking and the device is designed to be used on networks without internet connections. On networks with internet connections we could forward events from the device, via a server and APNS push notifications, but that isn't valid here.
Events occur on our device and are forwarded to clients, who are subscribed to Server-Sent Events. On macOS this works well and the application can receive updates and show Notification Center notifications fine.
On iOS we are using a BGAppRefreshTaskRequest with time interval set to 1 minute, but it appears that we get scheduled only every few hours. This isn't very useful as notifications just arrive in batches rather than in a timely manner. All normal networking is closed when the app goes into the background, so we cannot keep the SSE request open.
Another idea which we haven't tried yet: Creating a new endpoint on the device which keeps the connection open until a notification arrives, then using background URLSession to poll on that endpoint. Would that work? It seems like a mis-use of the API perhaps?
Networking
RSS for tagExplore the networking protocols and technologies used by the device to connect to Wi-Fi networks, Bluetooth devices, and cellular data services.
Post
Replies
Boosts
Views
Activity
I am trying to create an app that lets the user send Wake On LAN calls to computers in the local network. I created a small package that uses BSD sockets (https://github.com/pultar/WakeOnLAN/blob/main/Sources/CWakeOnLAN/wol.c) to send the magic packet. For now, I select "en0" manually as the interface.
The app works in the simulator but fails on a real device. I also noticed that I can test the package when I only use the terminal and Swift Package Manager but not from a CLI within XCode. In either case, I observe:
"No route to host"
Following previous post in the forum (see below), I figured I require the multicast entitlement, which I was granted and could add in the Xcode project settings and on Apple Developer together with my App Bundle ID.
However, even after activating the entitlement for my app, I observe the same error.
I'm attempting to build an app the broadcasts on the local network and awaits responses to those broadcast requests. However, the app does not receive the responses. Essentially, the app broadcasts "DISCOVER:1000" to 10.11.21.255, and expects "ADDRESS:10.11.21.100", but never receives it. I built a test client in python, and it works as expected. Running tcpdump on the server shows the response being sent by the server. It just never reaches the ios app.
In case it matters, I have the multicast entitlement for the app and local network enabled in Info.plist.
import Foundation
import Network
class UDPClient: ObservableObject {
private var connection: NWConnection?
private let networkQueue = DispatchQueue(label: "com.example.udp")
@Published var isReady = false
private var isListening = false
func connect() {
let host = "10.11.21.255"
let port = UInt16(12345)
let endpoint = NWEndpoint.hostPort(host: NWEndpoint.Host(host), port: NWEndpoint.Port(integerLiteral: port))
connection = NWConnection(to: endpoint, using: .udp)
connection?.stateUpdateHandler = { [weak self] state in
switch state {
case .ready:
self?.networkQueue.async {
print("Connection ready")
self?.startReceiving()
DispatchQueue.main.async {
self?.isReady = true
}
}
case .failed(let error):
print("Connection failed: \(error)")
DispatchQueue.main.async {
self?.isReady = false
}
case .waiting(let error):
print("Connection waiting: \(error)")
DispatchQueue.main.async {
self?.isReady = false
}
default:
DispatchQueue.main.async {
self?.isReady = false
}
break
}
}
connection?.start(queue: networkQueue)
}
func send() {
let message = "DISCOVER:1000"
guard let data = message.data(using: .utf8) else {
print("Failed to convert message to data")
return
}
guard let connection = self.connection else {
return
}
networkQueue.async { [weak self] in
print("Attempting to send message...")
guard let self = self else { return }
if self.isReady {
// Ensure we're listening before sending
if !self.isListening {
self.startReceiving()
// Add a small delay to ensure the receiver is ready
self.networkQueue.asyncAfter(deadline: .now() + 0.1) {
self.performSend(data: data, connection: connection)
}
} else {
self.performSend(data: data, connection: connection)
}
} else {
print("Connection is not ready. Retrying in 100ms...")
self.networkQueue.asyncAfter(deadline: .now() + 0.1) {
self.send()
}
}
}
}
private func performSend(data: Data, connection: NWConnection) {
connection.send(content: data, completion: .contentProcessed { error in
if let error = error {
print("Failed to send: \(error)")
} else {
print("Send completed successfully")
}
})
}
private func startReceiving() {
print("Starting to receive messages...")
isListening = true
connection?.receiveMessage { [weak self] content, context, isComplete, error in
guard let self = self else { return }
if let error = error {
print("Receive error: \(error)")
return
}
if let data = content {
print("Received data: \(data)")
if let responseString = String(data: data, encoding: .utf8) {
print("Received response: \(responseString)")
} else {
print("Received data could not be converted to string.")
}
} else {
print("No data received.")
}
// Continue receiving
self.startReceiving()
}
}
func disconnect() {
networkQueue.async { [weak self] in
self?.connection?.cancel()
self?.isListening = false
DispatchQueue.main.async {
self?.isReady = false
}
print("Disconnected")
}
}
}
My main view:
import SwiftUI
struct ContentView: View {
@StateObject private var udpClient = UDPClient()
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
.onAppear() {
udpClient.connect()
udpClient.send()
}
}
}
#Preview {
ContentView()
}
When I was attempting to establish a TCP connection using NWConnection on a physical iPhone, the connection consistently fails with the error:
connection did change state, new: waiting(POSIXErrorCode(rawValue: 50): Network is down)
connection did change state, new: preparing
connection did change state, new: waiting(POSIXErrorCode(rawValue: 50): Network is down)
However, when running the same code in the iOS Simulator, the connection succeeds without issues.
I have already granted the app permission to access the local network by selecting "Allow [App Name] to find devices on the local network" when prompted.
The issue persists even after restarting the app, device, and server.
Additionally, I have configured the Info.plist file with the following keys:
NSAllowsLocalNetworking
NSLocalNetworkUsageDescription
Here is my code:
func start() -> NWConnection {
let myHost: NWEndpoint.Host = "192.168.1.154" // My MacBook
let myPort: NWEndpoint.Port = 1234
let connection = NWConnection(to: .hostPort(host: myHost, port: myPort), using: .tcp)
connection.stateUpdateHandler = { newState in
print("connection did change state, new: \(newState)")
}
connection.start(queue: .main)
return connection
}
Development environment:
Xcode 15.3
MacOS 14.4.1
Device OS: iOS 18.1
Our company has a VPN client that we develop and it works on 14.x and it was working on 15.x but ever since I have upgraded to 15.1.1, I do not see any traffic being sent to the TUN interface even though I have it configured as the default route. Can anyone provide guidance or insight into what might have changed around the Network Extensions that could have caused this?
Unfortunately I cannot tell if this was happening on 15.0.1. Some things I have tried, to no avail, is disable the firewall and uninstalling/installing of the VPN client. I have no other filters installed that could be interfering. When I try and ping an address I should be able to reach, I get "no route to host"
I have also used Wireshark and have observed zero traffic going to the TUN interface.
NOTE, networking works fine when the VPN client is not connected.
Hi,
I've read a bunch of threads regarding the changes in Sonoma and later requiring Location permission for receiving SSIDs. However, as far as I can see, in Sequoia 15.1 SSIDs and BSSIDs are empty regardless.
In particular, this makes it not possible to use associate(withName:) and associate(withSSID:) because the network object returned by scanForNetwork(withSSID: "...") has its .ssid and .bssid set to nil.
Here is an example:
First we have a wrapper to call the code after the location permission is authorized:
import Foundation
import CoreLocation
class LocationDelegate: NSObject, CLLocationManagerDelegate {
var onAuthorized: (() -> Void)?
var onDenied: (() -> Void)?
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
let authStatus = manager.authorizationStatus
print("Location authorization status changed: \(authStatusToString(authStatus))")
if authStatus == .authorizedAlways {
onAuthorized?()
} else if authStatus == .denied || authStatus == .restricted {
onDenied?()
}
}
}
let locationManager = CLLocationManager()
let locationDelegate = LocationDelegate()
func authorizeLocation(onAuthorized: @escaping () -> Void, onDenied: @escaping () -> Void) {
let authStatus = locationManager.authorizationStatus
print("Location authorization status: \(authStatusToString(authStatus))")
if authStatus == .notDetermined {
print("Waiting for location authorization...")
locationDelegate.onAuthorized = onAuthorized
locationDelegate.onDenied = onDenied
locationManager.delegate = locationDelegate
locationManager.requestAlwaysAuthorization()
} else if authStatus == .authorizedAlways {
onAuthorized()
} else if authStatus == .denied || authStatus == .restricted {
onDenied()
}
RunLoop.main.run()
}
func authStatusToString(_ status: CLAuthorizationStatus) -> String {
switch status {
case .notDetermined:
return "Not Determined"
case .restricted:
return "Restricted"
case .denied:
return "Denied"
case .authorizedAlways:
return "Always Authorized"
case .authorizedWhenInUse:
return "Authorized When In Use"
@unknown default:
return "Unknown"
}
}
Then, a demo program itself:
import Foundation
import CoreWLAN
import Network
let client = CWWiFiClient.shared()
guard let interface = client.interface() else {
print("No wifi interface")
exit(1)
}
authorizeLocation(
onAuthorized: {
do {
print("Scanning for wifi networks...")
let scanResults = try interface.scanForNetworks(withSSID: nil)
let networks = scanResults.compactMap { network -> [String: Any]? in
return [
"ssid": network.ssid ?? "unknown",
"bssid": network.bssid ?? "unknown"
]
}
let jsonData = try JSONSerialization.data(withJSONObject: networks, options: .prettyPrinted)
if let jsonString = String(data: jsonData, encoding: .utf8) {
print(jsonString)
}
exit(0)
} catch {
print("Error: \(error)")
exit(1)
}
},
onDenied: {
print("Location access denied")
exit(1)
}
)
When launched, the program asks for permission, and after that, is shown as enabled in Privacy & Security Settings panel.
Here is the output where it can be seen that the scan is performed after location access was authorized, and regardless of that, all ssids are empty:
Location authorization status: Not Determined
Waiting for location authorization...
Location authorization status changed: Always Authorized
Scanning for wifi networks...
[
{
"ssid" : "unknown",
"bssid" : "unknown"
},
{
"ssid" : "unknown",
"bssid" : "unknown"
},
.... further omitted
Calling scanForNetworks() with explicitly specified network name does this as well, returns a CWNetwork object with .ssid / .bssid = nil.
Hi,
I'm trying to set up automated backups on my machine using a combination of restic, a wrapper script, and a launchd agent, but I think I'm hitting a problem with the local network privacy dialogue.
Basically, the script sets up the environment variables for Restic, which then tries to backup to a local REST server. Problem is, when trying to do that, I get the following error:
Fatal: unable to open config file: Head "https://X:X@X.X.X.network:8000/X/X.X.X.network/config": dial tcp 192.168.50.229:8000: connect: no route to host
So it resolves DNS just fine, but can't connect to the local server. I tried a couple of things, tools such as ping work and can ping the local server, but nothing I do fixes the issue with restic itself. After reading about the network privacy feature, which I loved by the way, I believe it's the culprit here.
This is the .plist file I'm using, which lives in ~/Library/LaunchAgents/com.james.local-backup.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.james.local-backup</string>
<key>ProgramArguments</key>
<array>
<string>/Users/james/.local/bin/replicator</string>
<string>--backup</string>
<string>rest:https://X.X.X.network:8000/X/X.X.X.network</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
<key>XDG_CONFIG_HOME</key>
<string>/Users/james/.config</string>
</dict>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>13</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>StandardErrorPath</key>
<string>/tmp/com.user.backup.err</string>
<key>StandardOutPath</key>
<string>/tmp/com.user.backup.out</string>
<key>ProcessType</key>
<string>Background</string>
</dict>
</plist>
The local network dialogue never shows up, so I can't give the wrapper script or restic access to the local network, which I assume is why it can't connect to the local server.
Any way I can solve this? I could build a proper Swift CLI that calls restic, but I assume I'd hit the same issue. Plus, it seems overkill for my needs.
I am developing a USB networking accessory using the CDC ECM or NCM protocol and I would like to know what are the MacOS and iPadOS requirements to connect to such a device.
I have a prototype CDC ECM device developed that uses static IPv4 addressing which I can connect to an Arch Linux host and ping, but I am unable to have the same success from my Mac Studio M1 running Sequoia 15.1.1. The device shows up under 'Other Services' with 'Not connected' status, whether I leave it with the default settings or change it to 'Configure IPv4 -> Manually' and then set the appropriate IP address / Subnet mask / Router.
From a discussion on Github, it seems that the ECM device must support NetworkConnection notification in order to work with MacOS. Can you point me to where this is documented and whether there are other expectations/requirements around USB network adapters?
My end goal is to make an embedded device that communicates to MacOS and iPadOS devices/apps over USB CDC NCM with a simple UDP socket listener.
Thank you in advance for any help you can provide.
I’ve encountered an issue with an app that includes a Local Push Connectivity extension. After a fresh install of the app, the Local Network Alert appears when calling NEAppPushManager.save(). The alert message is:
“This app would like to find and connect to devices on your local network. This app will be able to discover and connect to devices on the networks you use.”
Here is the relevant code:
` pushManager.providerConfiguration = NEAppPushManager.providerConfiguration(with: settings, system: system)
if settings.ssids.isEmpty {
fatalError("☠️ The PushManagerSettings.ssids should NEVER be empty!")
}
pushManager.matchSSIDs = !settings.ssids.isEmpty
? Array(settings.ssids)
: []
return pushManager.save()`
Questions:
1. Why does the Local Network Alert appear?
I suspect it is related to pushManager.matchSSIDs, which interacts with the local network to match specific SSIDs.
2. What happens if the user clicks “Don’t Allow”?
Based on my testing, everything seems to work fine even if the user denies the permission.
Would you happen to know why this is happening and if denying the alert could cause any issues down the line?
It is not possible to establish a point-to-point WiFi connection between iPhone models 15 and 16 (iOS 18) and the HiFlying HF-LPB100-1 module used by our IoT devices to control Yale locks: https://www.yaleconnecthub.com/en/compatible-products/hub
The message displayed on the iPhone WiFi network settings screen when selecting the HF-LPB100-1 module network states 'Unable to connect'.
It is important to highlight that all iPhone models and previous OS versions are compatible with this WiFi module (antenna + chipset).
We already made a post in the Feedback Assistence platform FB15809338 (Provisioning an IoT devise under iOS 18 - Wi-Fi incompatibility )
STEPS TO REPRODUCE
Plug in the Yale Connect Hub model YALE-4971 (with HF-LPB100-1 module) > The device's WiFi module will start reporting its network.
On an iPhone 15 or 16 -using iOS 18 - display the WiFi network configuration screen and select Yale´s device network (it is named Yale-xxxxxx).
Select the Yale network for the iPhone to connect point-to-point.
An error message will appear: Unable to connect.
Hi
I just encountered an reachability detection problem by calling SCNetworkReachabilityGetFlags function in iOS 16.
what did I do:
on device iPhone 12, iOS 16.1.1, turn on Airplane Mode, call SCNetworkReachabilityGetFlags, got flags = kSCNetworkReachabilityFlagsTransientConnection | kSCNetworkReachabilityFlagsReachable
on device iPhone 7, iOS 14.5.1, turn on Airplane Mode, call SCNetworkReachabilityGetFlags, got flags = 0
what I expect:
I'm expecting SCNetworkReachabilityGetFlags on my iOS 16.1 device behave same as my iOS 14.5 device, returning flags = 0. It's inappropriate returning kSCNetworkReachabilityFlagsReachable in this case.
Thank you!
Hello, all,
I'm new to iOS development and working on a project with the following setup:
Architecture:
Windows PC running Ubuntu (WSL) hosting a WebSocket Server with self-signed SSL
Python GUI application as a client to control iOS app
iOS app as another client on physical iPhone
Server running on wss://***.***.***.1:8001 (this is the mobile hotspot IP from Windows PC which the iPhone is needed to connect to as well)
Current Status:
✓ Server successfully created and running
✓ Python GUI connects and functions properly
✓ iOS app initially connects and communicates for 30 seconds
✗ iOS connection times out after 30 seconds
✗ Map updates from GUI don't sync to iOS app
Error Message in Xcode terminal:
WebSocket: Received text message
2024-11-25 15:49:03.678384-0800 iVEERS[1465:454666] Task <CD21B8AD-86D9-4984-8C48-8665CD069CC6>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2103, _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <CD21B8AD-86D9-4984-8C48-8665CD069CC6>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalWebSocketTask <CD21B8AD-86D9-4984-8C48-8665CD069CC6>.<1>"
), NSLocalizedDescription=The request timed out., NSErrorFailingURLStringKey=wss://***.***.***.1:8001/, NSErrorFailingURLKey=wss://***.***.***.1:8001/, _kCFStreamErrorDomainKey=4}
Technical Details:
Using iOS built-in URLSessionWebSocketTask for WebSocket connection
Self-signed SSL certificate
Transport security settings configured in Info.plist
Map updates use base64 encoded PNG data
Questions:
What's causing the timeout after 30 seconds?
How can I maintain a persistent WebSocket connection?
Why aren't map updates propagating to the iOS client?
Any guidance/suggestions would be greatly appreciated. Please let me know if additional code snippets would help on what I currently have.
Hello,
I have a very basic quic client implementation. When you run this code with some basic quic server, you will see that we can't get a handle to stream identifier 0, but behavior is actually different when we use URLSession/URLRequest, and I can see that some information can be sent over the wire for stream identifier 0 with that implementation.
You can find both code below I'm using to test this.
I'd like to get more info about how I can use stream identifier 0 with NWMultiplexGroup, if I can't use it with NWMultiplexGroup, I need a workaround to use stream with id 0 and use multiple streams over the same connection.
import Foundation
import Network
let dispatchQueue = DispatchQueue(label: "quicConnectionQueue")
let incomingStreamQueue = DispatchQueue(label: "quicIncStreamsQueue")
let outgoingStreamQueue = DispatchQueue(label: "quicOutStreamsQueue")
let quicOptions = NWProtocolQUIC.Options()
quicOptions.alpn = ["test"]
sec_protocol_options_set_verify_block(quicOptions.securityProtocolOptions, { (sec_prot_metadata, sec_trust, complete_callback) in
complete_callback(true)
}, dispatchQueue)
let parameters = NWParameters(quic: quicOptions);
let multiplexGroup = NWMultiplexGroup(to: NWEndpoint.hostPort(host: "127.0.0.1", port: 5000))
let connectionGroup = NWConnectionGroup(with: multiplexGroup, using: parameters)
connectionGroup.stateUpdateHandler = { newState in
switch newState {
case .ready:
print("Connected using QUIC!")
let _ = createNewStream(connGroup: connectionGroup, content: "First Stream")
let _ = createNewStream(connGroup: connectionGroup, content: "Second Stream")
break
default:
print("Default hit: newState: \(newState)")
}
}
connectionGroup.newConnectionHandler = { newConnection in
// Set state update handler on incoming stream
newConnection.stateUpdateHandler = { newState in
// Handle stream states
}
// Start the incoming stream
newConnection.start(queue: incomingStreamQueue)
}
connectionGroup.start(queue: dispatchQueue)
sleep(50)
func createNewStream(connGroup: NWConnectionGroup, content: String) -> NWConnection? {
let stream = NWConnection(from: connectionGroup)
stream?.stateUpdateHandler = { streamState in
switch streamState {
case .ready:
stream?.send(content: content.data(using: .ascii), completion: .contentProcessed({ error in
print("Send completed! Error: \(String(describing: error))")
}))
print("Sent data!")
printStreamId(stream: stream)
break
default:
print("Default hit: streamState: \(streamState)")
}
}
stream?.start(queue: outgoingStreamQueue)
return stream
}
func printStreamId(stream: NWConnection?)
{
let streamMetadata = stream?.metadata(definition: NWProtocolQUIC.definition) as? NWProtocolQUIC.Metadata
print("stream Identifier: \(String(describing: streamMetadata?.streamIdentifier))")
}
URLSession/URLRequest code:
import Foundation
var networkManager = NetworkManager()
networkManager.testHTTP3Request()
sleep(5)
class NetworkManager: NSObject, URLSessionDataDelegate {
private var session: URLSession!
private var operationQueue = OperationQueue()
func testHTTP3Request() {
if self.session == nil {
let config = URLSessionConfiguration.default
config.requestCachePolicy = .reloadIgnoringLocalCacheData
self.session = URLSession(configuration: config, delegate: self, delegateQueue: operationQueue)
}
let urlStr = "https://localhost:5000"
let url = URL(string: urlStr)!
var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 60.0)
request.assumesHTTP3Capable = true
self.session.dataTask(with: request) { (data, response, error) in
if let error = error as NSError? {
print("task transport error \(error.domain) / \(error.code)")
return
}
guard let data = data, let response = response as? HTTPURLResponse else {
print("task response is invalid")
return
}
guard 200 ..< 300 ~= response.statusCode else {
print("task response status code is invalid; received \(response.statusCode), but expected 2xx")
return
}
print("task finished with status \(response.statusCode), bytes \(data.count)")
}.resume()
}
}
extension NetworkManager {
func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) {
let protocols = metrics.transactionMetrics.map { $0.networkProtocolName ?? "-" }
print("protocols: \(protocols)")
}
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
if challenge.protectionSpace.serverTrust == nil {
completionHandler(.useCredential, nil)
} else {
let trust: SecTrust = challenge.protectionSpace.serverTrust!
let credential = URLCredential(trust: trust)
completionHandler(.useCredential, credential)
}
}
}
Hi Team
We are facing a problem in our app for one particular user the url session is giving below error. Rest for all the users its working fine. Below is the complete error we get from user device.
{"type":"video_player","error":"Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://api.vimeo.com/videos/1020892798, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .<4>, _NSURLErrorRelatedURLSessionTaskErrorKey=(\n "LocalDataTask .<4>"\n), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://api.vimeo.com/videos/1020892798, NSUnderlyingError=0x301ea8930 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9836, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9836, _NSURLErrorNWPathKey=satisfied (Path is satisfied), viable, interface: pdp_ip0, ipv6, dns, expensive, uses cell}}, _kCFStreamErrorCodeKey=-9836}"}
Device info
device_type iOS
device_os_version 18.1.1
device_model iPhone 11
Please let me know how we can resolve for one particular user. Or what we can adivse.
Hi, I am new to swift and IOS development, I was developing an app which can be used to communicating between Apple Watch and iPhone.
Something strange occurred when I was trying to observe the status of the message(UserInfo) sent by func transferUserInfo(_ userInfo: [String : Any] = [:]) -> WCSessionUserInfoTransfer.
I was trying to observe isTransferring(a boolean value) in WCSessionUserInfoTransfer which was returned by the function mentioned above, but it seems cannot be updated even if the message queue was empty, it seems to always be True.
Here is my sample code:
let transfer = session.transferUserInfo(message)
if transfer.isTransferring {
Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { timer in
print("Queued message count: \(self.session.outstandingUserInfoTransfers.count), isTransferring:\(transfer.isTransferring)")
if !transfer.isTransferring {
timer.invalidate()
// irrelevant codes...
}
}
} else {
// other irrelevant codes...
}
Appreciate if anyone can help me out of this problem.
Best wishes.
We are checking for cellular mode using the code below.
When the code below is executed, is it correct to convey the status value of the actually connected cellular environment?
Sometimes HSDPA or WCDMA is output.
I would like to inquire under what conditions the value is output.
[Code]
func getCellularConnectionType() -&gt; String {
if #available(iOS 14.1, *) {
if let radioAccessTechnology = networkInfo.serviceCurrentRadioAccessTechnology?.values.first {
Debug.log("Radio Access Technology: (radioAccessTechnology)")
switch radioAccessTechnology {
case CTRadioAccessTechnologyLTE:
return "LTE"
case CTRadioAccessTechnologyNRNSA:
return "5G-NSA"
case CTRadioAccessTechnologyNR:
return "5G-SA"
default:
return "ETC"
}
}
}
return "Cellular"
}
In my case there are three interfaces. I had a mental model that I now believe is incorrect.
If any of the 3 interfaces is "satisfied", then I get one message telling me so. I guess if that one interface goes down, then I should get a second message that tells me that (this is hard to test as Xcode keeps disconnecting from my device when I switch to Settings to change things).
in my case, wifi and cellular are both on. I launch the app, get notified that wifi is satisfied, but nothing on cellular.
So my guess is there is a hierarchy: wired, wifi, and cellular. If the highest priority path is available, the others are assumed "off" since you have a path. Thus, you will never get "satisfied" for more than one path.
Correct?
Note that AsyncDNSResolver is a fairly new Apple sponsored framework (search for it).
I am trying to resolve a hostname (behind a CNAME) but cannot. In face even "ping" in mac Terminal can't.
The host I start with is apidev.leaptodigital.com - when I ask for its CNAME:
resolver.queryCNAME(name: "apidev.leaptodigital.com")
I get:
salespro-dev-server-2.eba-uxpxmksr.us-east-1.elasticbeanstalk.com
Great! But nothing I try with that hostname returns an IP address. I tried queryCNAME again, then queryA, then queryAAAA.
Yet I can send http traffic to this host, so its getting resolved somewhere.
Note that nslookup in Terminal finds it just fine.
David
PS: tried older APIs like CFHostStartInfoResolution but they don't return anything either. Did not try getHostName as its use is discouraged.
I have tests where I connect to NEPacketTunnelProvider. I run tests with circleci and fastlane, on self hosted intel and arm macs. I updated macs from macOS 13 to macOS 14 and the tests on arm stopped connecting, while the same tests on intel kept working as usual. Moreover, I noticed the tests don't work when run from circleci and fastlane. If I cancel the job and click "connect" myself on the app that stayed hanging from the cancelled tests, the connection will succeed. But if the tests are running, the connection will fails. Running the tests from xcode succeeds too.
These are the logs from the tunnel. Could you suggest me where to dig? Or maybe you can see the issue from the logs?
Tunnel logs when they fail
With little knowledge on C++, but help from ChatGPT, I am trying to write a plugin for OBS.
I would like to include a bonjour service in the plugin. I assume that the framework is already present on every Mac, but I don't know where it resides, and how to #include it.
Anyone can help me here?
Thanks in advance
https://developer.apple.com/forums/thread/735862?login=true