I have been polishing an app that connects and communicates between a tvOS app I created and a iPadOS app that I also created. Connection works fantastic! However, for some reason when the user selects the button to open the DevicePicker provided by this API and then selects a iPad device the notification that comes across the the iPad reads, "Connect your Apple TV to "AppName" on this iPhone.
Is this a bug or am I missing some configuration in maybe Info.plist or a modifier I need to add the DevicePicker for it to communicate the proper device identification? I have everything setup in both app Info.plist files to connect and work fine, but the notification saying iPhone on an iPad is sadly a small detail I would love to change. So...not sure if I found a bug or if I am missing something.
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.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Created
Hi,
I've created a packet tunnel but my packetFlow object isn't get called with any packets. Do I need to do something else to configure the packetFlow? Maybe I have to link it to a NWUDPSession?
Thanks,
Dave
class PacketTunnelProvider: NEPacketTunnelProvider {
override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
let settings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: tunnelRemoteAddress)
settings.ipv4Settings = NEIPv4Settings(addresses: [tunnelRemoteAddress], subnetMasks: ["255.255.255.255"])
settings.ipv4Settings?.includedRoutes = [NEIPv4Route.default()]
setTunnelNetworkSettings(settings) { error in
completionHandler(error)
self.readPacketObjects()
}
}
private func readPacketObjects() {
self.packetFlow.readPacketObjects() { packets in
// It never gets here.
self.logMessage("Got '\(packets.count)' packet(s)")
self.packetFlow.writePacketObjects(packets)
self.readPacketObjects()
}
}
}
Hi everyone!
I'm developing a system where an application running in a VM communicates with the host operating system's components using vsock sockets (VZVirtioSocketDevice in Virtualization.framework). Both systems are running macOS. There may be multiple guests, and the existing implementation for other OSes relies on VM's CID to differentiate them.
In macOS, getting the CID from inside the guest VM is straightforward—it is returned by IOCTL_VM_SOCKETS_GET_LOCAL_CID.
However, in macOS the regular vsock API is not available on the host side, replaced by Virtualization.framework. I could not find anything in the Virtualization.framework's documentation that could be used to query (or set?) the CID for the specific virtual machine instance (which is certainly possible on other platforms utilizing Virtio drivers, e.g. Linux/QEMU). Am I overlooking something?
1、Does Captive Portal documentation for IOS exist for developers?
If so, please provide a link.
We have product for network monitoring and we are't able to add support auto-instrumenting the networking requests for URLSession async/wait methods as these methods are't exposed to dynamic environment or not exposed to ObjC and we con't use any of the run-time functionality and we con't override these methods as these methods are't public.
looking for a way to add some kind of logic so that when customers use our product they don't have to add any code from there end to monitor this system.
Hi everyone,
I'm currently working on a project where I need to send multicast packets across all available network interfaces using Apple Network Framework's NWConnectionGroup. Specifically, the MacBook (device I am using for sending multicast requests, MacOS: 15.1) is connected to two networks: Wi-Fi (Network 1) and Ethernet (Network 2), and I need to send multicast requests over both interfaces.
I tried using the .requiredInterface property as suggested by Eskimo in this post, but I’m running into issues.
It seems like I can't create an NWInterface object because it doesn't have any initializers.
Here is the code which I wrote:
var multicast_group_descriptor : NWMulticastGroup
var multicast_endpoint : NWEndpoint
multicast_endpoint = NWEndpoint.hostPort(host: NWEndpoint.Host("234.0.0.1"), port: NWEndpoint.Port(rawValue: 49154)!)
var connection_group : NWConnectionGroup
var multicast_params : NWParameters
multicast_params = NWParameters.udp
var interface = NWInterface(NWInterface.InterfaceType.wiredEthernet)
I get following error:
'NWInterface' cannot be constructed because it has no accessible initializers
I also experimented with the .requiredInterfaceType property. Even when I set it to .wiredEthernet and then change it to .wifi, I am still unable to send requests over the Wi-Fi network.
Here is the code I wrote:
var multicast_params : NWParameters
multicast_params = NWParameters.udp
multicast_params.allowLocalEndpointReuse = true
multicast_params.requiredInterfaceType = .wiredEthernet
var ip = multicast_params.defaultProtocolStack.internetProtocol! as! NWProtocolIP.Options
ip.disableMulticastLoopback = true
connection_group = NWConnectionGroup(with: multicast_group_descriptor, using: multicast_params)
connection_group.stateUpdateHandler = { state in
print(state)
if state == .ready {
connection_group.send(content: "Hello from machine on 15".data(using: .utf8)) { error in
print("Send to mg1 completed on wired Ethernet with error \(error?.errorCode)")
var params = connection_group.parameters
params.requiredInterfaceType = .wifi
connection_group.send(content: "Hello from machine on 15 P2 on Wi-Fi".data(using: .utf8)) { error in
print("Send to mg1 completed on Wi-Fi with error \(error?.errorCode)")
}
}
}
}
Is this expected behavior when using NWConnectionGroup? Or is there a different approach I should take to ensure multicast requests are sent over both interfaces simultaneously?
Any insights or suggestions would be greatly appreciated!
Thanks in advance,
Harshal
We found that when we only set one App Category and one Traffic Category in Xcode entitlements, the built application will contain all App Categories and Traffic Categories in the embedded.mobileprovision file, is it expected?
Entitlements file:
<?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>com.apple.developer.networking.slicing.appcategory</key>
<array>
<string>streaming-9001</string>
</array>
<key>com.apple.developer.networking.slicing.trafficcategory</key>
<array>
<string>avstreaming-7</string>
</array>
</dict>
</plist>
embedded.mobileprovision:
<key>Entitlements</key>
<dict>
<key>com.apple.developer.networking.slicing.appcategory</key>
<array>
<string>communication-9000</string>
<string>games-6014</string>
<string>streaming-9001</string>
</array>
<key>com.apple.developer.networking.slicing.trafficcategory</key>
<array>
<string>defaultslice-1</string>
<string>video-2</string>
<string>background-3</string>
<string>voice-4</string>
<string>callsignaling-5</string>
<string>responsivedata-6</string>
<string>avstreaming-7</string>
<string>responsiveav-8</string>
</array>
I have granted local network permissions, but sometimes I get a second confirmation popup, what is the timing of the secondary popup?
Hi everyone,
I’ve been working with the NEPacketTunnelProvider class and came across the cancelTunnelWithError() method. The documentation mentions its general purpose but doesn’t provide much clarity on how and when it should be called.
From what I’ve gathered in other forum posts, it seems that cancelTunnelWithError() should be called within my own implementation of the stopTunnel() method, but I’m not entirely sure if that’s the correct usage or whether there are specific scenarios where this applies.
Here are my specific questions:
Is it correct to always call cancelTunnelWithError() in my implementation of stopTunnel()?
Are there specific conditions or scenarios where cancelTunnelWithError() is the preferred way to terminate a tunnel session, rather than other termination methods?
What does the system do with the error that I pass to cancelTunnelWithError()? Does it have an impact on how the session termination is handled?
Are there best practices or common pitfalls to avoid when using cancelTunnelWithError()?
Any insights, examples, or guidance would be greatly appreciated!
Thanks in advance for your help!
In https://developer.apple.com/forums/thread/128705?answerId=405119022#405119022, it is said that
But if it’s holding up connections that match the on demand rules, that’s the correct behaviour.
So if there was an on demand rule to connect for all domains (Connect rule without any matching criteria), all traffic would be held up while in the connecting state. The problem is that a customer can have SSO configured so that auth happens outside of the vpn app.
So sequence would be
Connect for all domains on demand rule triggers vpn connection
VPN, in order to connect, tries auth through a broker app.
VPN is in connecting state and blocks broker app traffic and so auth cannot complete and it cannot connect.
I tried adding an on demand rule for EvaluateConnection and never connect for the auth domains. However, that caused the vpn to never be triggered to connect.
Is it possible to support the scenario of an on demand rule to connect for all domains while having a vpn connection dependent on auth done in a separate app? Do you have any recommendations?
I developed a Content Filter using the Network Extension, and when deployed to a batch of hosts (50 +), the installation worked for most of them, but there were six exceptions: five of them were macOS 10.15 and one of them was macOS 12.5.
The phenomenon of these 6 hosts is: in the System Settings->Network, two content filters with the same name appear. When one of the content filters with the same name is clicked, shows "Please use 'X Agent Extension' to control this content filter configuration" ('X Agent Extension' is the program I developed, this content filter can be deleted by clicking the minus sign in the lower left corner). Click on another content filter with the same name, shows 'Please use 'null' to control this content filter configuration', (but this content filter can't be removed by clicking the minus sign in the bottom left corner).
These systems are clean, use CLI 'systemextensionsctl list', and have only one systemextension in the output (this systemextension is my content filter). Online reference "https://forums.macrumors.com/threads/how-to-delete-custom-dns-profile-from-network-preference.2293322/" this paper, by closing the SIP, and delete file '/Library/Preferences/com.apple.networkextension.plist', then restart the system can remove the abnormal content filters with the same name. After restarting the system and reinstalling my content filter, the two content filters with the same name disappear (only the Content Filter I reinstalled) and the exception scenario cannot be repeated.
I would like to know, why do I have two content filters with the same name, how can I avoid this phenomenon, is there a way to remove the wrong content filter without closing SIP.
I accidentally used -f and now Private Relay is not working with firewall active, but if i disable it, it works. Need the /etc/pf.conf original data
Topic:
App & System Services
SubTopic:
Networking
I've implemented a custom system extension VPN for macOS, using Packet Tunnel Provider.
I have a XPC connection, from the containing app to the (system) extension.
What is the expected behavior after the Mac's sleep/wake?
Will the same XPC remain valid? Should I start a new connection?
I have an iOS app which contains a Network Extension that subclasses the NEPacketTunnelProvider, acting as a packet-tunnel VPN. After deploying the app on the device as a regular app, it runs the following code fragment:
NETunnelProviderManager.loadAllFromPreferences { managers, _ in
self.manager = managers?.first ?? NETunnelProviderManager()
self.manager.protocolConfiguration = getConfiguration()
self.manager.saveToPreferences { error in
// Handle errors or show a "Connect" button in the UI
}
}
This asks the user to install the extension as a "Device VPN". I can then use try? self.manager?.connection.startVPNTunnel() to start the VPN (and later stop it when needed). So far, this works fine.
Now, I want to deploy the app with an MDM and set it up as the "custom VPN" of a "Per-App VPN". I have tested the setup using
a real MDM, AND
using the "development" setup described in NETunnelProviderManager.
In both cases, the "Per-App VPN" shows up as a VPN in the "Settings" app.
However, in both cases I am unable to retrieve, configure or use the "Per-App VPN". The code fragment posted above returns no NETunnelProviderManager at all. When instantiating one on my own and triggering self.manager.saveToPreferences(), it queries the user to install a "Device VPN". While I can control and use the latter, this is clearly not what I want after having gone through the pain of installing the "Per-App VPN".
How can I retrieve the NETunnelProviderManager of the "Per-App VPN"? And then use it to configure and control the VPN connection? (Ideally, I would like to use the same app and the same Network Extension for both use cases, leaving the choice of which VPN type to use to the user or the user's MDM administrator.)
Topic:
App & System Services
SubTopic:
Networking
Dear Team,
I was previously able to access a non-secure HTTP API in my Ionic-built app. However, I am now encountering an error where the API requests are being rejected. Interestingly, this API works perfectly on Android and web platforms without any issues.
As part of my troubleshooting, I have already added the following lines to my Info.plist file:
`<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>`
Could you kindly suggest any alternative solutions or additional settings required to access this HTTP API?
Your help would be greatly appreciated.
Thank you,
Mozib
Hi All, I am trying to write an NWProtocolFramerImplementation that will run after Websockets. I would like to achieve two goals with this
Handle the application-layer authentication handshake in-protocol so my external application code can ignore it
Automatically send pings periodically so my application can ignore keepalive
I am running into trouble because the NWProtocolWebsocket protocol parses websocket metadata into NWMessage's and I don't see how to handle this at the NWProtocolFramerImplementation level
Here's what I have (see comments for questions)
class CoolProtocol: NWProtocolFramerImplementation {
static let label = "Cool"
private var tempStatusCode: Int?
required init(framer: NWProtocolFramer.Instance) {}
static let definition = NWProtocolFramer.Definition(implementation: CoolProtocol.self)
func start(framer: NWProtocolFramer.Instance) -> NWProtocolFramer.StartResult { return .willMarkReady }
func wakeup(framer: NWProtocolFramer.Instance) { }
func stop(framer: NWProtocolFramer.Instance) -> Bool { return true }
func cleanup(framer: NWProtocolFramer.Instance) { }
func handleOutput(framer: NWProtocolFramer.Instance, message: NWProtocolFramer.Message, messageLength: Int, isComplete: Bool) {
// How to write a "Message" onto the next protocol handler. I don't want to just write plain data.
// How to tell the websocket protocol framer that it's a ping/pong/text/binary...
}
func handleInput(framer: NWProtocolFramer.Instance) -> Int {
// How to handle getting the input from websockets in a message format? I don't want to just get "Data" I would like to know if that data is
// a ping, pong, text, binary, ...
}
}
If I implementing this protocol at the application layer, here's how I would send websocket messages
class Client {
...
func send(string: String) async throws {
guard let data = string.data(using: .utf8) else {
return
}
let metadata = NWProtocolWebSocket.Metadata(opcode: .text)
let context = NWConnection.ContentContext(
identifier: "textContext",
metadata: [metadata]
)
self.connection.send(
content: data,
contentContext: context,
isComplete: true,
completion: .contentProcessed({ [weak self] error in
...
})
)
}
}
You see at the application layer I have access to this context object and can access NWProtocolMetadata on the input and output side, but in NWProtocolFramer.Instance I only see
final func writeOutput(data: Data)
which doesn't seem to include context anywhere.
Is this possible? If not how would you recommend I handle this? I know I could re-write the entire Websocket protocol framer, but it feels like I shouldn't have to if framers are supposed to be able to stack.
WiFi and Bluetooth are both enabled on Mac and iPhone, neither device is connected to a network
Running MultipeerConnectivity on the Mac as Advertiser and iPhone as Browser, the invitation is sent from the phone and accepted by the mac, but the connection is then dropped. This doesn’t happen when the Advertiser is another iOS device.
STEPS TO REPRODUCE THE PROBLEM
We have created a small sample project that demonstrates the problem. It can be found at: https://github.com/eidria/Multipeer-Progress-Demo.git. It contains both a Mac app and a iOS app.
Run the Mac app and start Advertising
Run iOS app and start Browsing
The iOS app automatically issues an invitation to the browser (Mac) which accepts. Shortly after the connection is dropped.
None of my app's functionalities make use of local network. However, on launching the app on an iPad running iOS 18.2.1, I see an iOS prompt asking for local network permission by the app with a null usage description.
I know since the app does not have Privacy string for local network, I see the null message.
But my app does not use of local network so I am confused why I see this alert.
I have an idea for a game where the Apple TV app acts as the host and discovers nearby iOS apps that can join the game. Each iOS app needs to be able to have the user draw, tap, etc and have all the events be delivered in real time to the Apple TV where the effects will be rendered immediately (imagine a co-op game played in your lounge room where guests user their own devices to control aspects of the UI on the shared Apple TV screen)
MPC is discontinued and DeviceDiscoveryUI is limited to only a single iOS device so I’m trying to figure out the best way to do the P2P networking.
Reading/watching videos suggests that using GKMatchMaker and friends seems like it might suffer from latency problems (because everything has to go via Game Centre - or does it?) plus I’m not sure how I’d deal with the fact that the owner of the Apple TV is likely to signed into the same game centre id on both the Apple TV and their own devices to which would mean they wouldnt be able to play because the host can’t invite “themselves” on another device (or can it?)
Soooo… I’m looking for suggestions on how best to move forward. I’ve read https://developer.apple.com/documentation/technotes/tn3151-choosing-the-right-networking-api which is very useful but there’s no clear suggestion that would work.
Using the Network for the real time messaging seems doable but dealing with discovery / invites seems like a massive pain that I’d prefer to use built-in libraries if possible.
Any suggestions would be gladly received. Thanks a lot
Topic:
App & System Services
SubTopic:
Networking
Tags:
GameKit
Nearby Interaction
Multipeer Connectivity
I am developing an App for iOS/iPhone that communicates with an external hardware.
The external hardware is a hotspot to which the iPhone connects and every 10 seconds this hardware sends data to the iPhone by opening a TCP connection on the local network to the indicated port.
On the iPhone side I use NWListener to retrieve the connections. When a connection is opened, I retrieve the data sent by the hardware and I close the connection.
Because I also need to have the exact position of the user I have activated the Location background mode using the CoreLocation framework.
If I put my application in the background everything works correctly. I retrieve the data every 10s as well as the changes in the user's positions.
After 15 minutes however, and it is very precise, the server (NWListener) no longer accepts connections as if there was a timeout or a limitation to having a server running in the background in an iOS application.
Can you help me?
Thanks
Topic:
App & System Services
SubTopic:
Networking