Hello,
is there any way to detect if current connectivity is using wired ethernet on iOS ?
Davie Scrève
Hello,
is there any way to detect if current connectivity is using wired ethernet on iOS ?
Davie Scrève
It’s hard to answer this without a more concrete definition of what you mean by “current connectivity”. I suspect you’re asking about the default route, in which case the best way forward is
NWPathMonitor
. For example:
let monitor = NWPathMonitor()
func startPathMonitor() {
self.monitor.pathUpdateHandler = { path in
print(path.usesInterfaceType(.wiredEthernet))
print("--")
}
self.monitor.start(queue: .main)
}
Note that I’m using
usesInterfaceType(_:)
here, because the default route might be a VPN and you need to test what interface that’s running over.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
It’s hard to answer this without a more concrete definition of what you mean by “current connectivity”. I suspect you’re asking about the default route, in which case the best way forward is
NWPathMonitor
. For example:
let monitor = NWPathMonitor()
func startPathMonitor() {
self.monitor.pathUpdateHandler = { path in
print(path.usesInterfaceType(.wiredEthernet))
print("--")
}
self.monitor.start(queue: .main)
}
Note that I’m using
usesInterfaceType(_:)
here, because the default route might be a VPN and you need to test what interface that’s running over.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"