What is the best way to detect if the Wifi is being used for Wireless Carplay or is just a normal network interface?
How to detect if Wifi is being used for CarPlay
To what end? If you have access to that information, what would you do with it?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
/Quinn,
Glad you asked. The main reason for my question is because our App is a Custom VPN. When connected to CarPlay we can query the system and get the Primary network interface which is the Cellular interface. But, once our Custom VPN app is running the Primary is now the VPN TUN instead of the Cellular interface, which we need to pass data. The typically way we get around this is to then query for all the Active interfaces, giving preference to Wifi over Cellular. So now we are trying to use the Wifi interface for data when it's being used for CarPlay. I suspect the same issue would occur when the phone is being used as a hotspot but I have not tested that.
In any case, I have found a "work around" that works. We now are looking at the WifiNetworkType and if it has a non-zero value do not use it.
We now are looking at the WifiNetworkType
The what now? That’s not an API I recognise. Can you point me at its documentation?
Coming back to your main issue, this is iOS, right? So you’re using an Network Extension packet tunnel provider, right?
If so, I’m a bit confused as to why you need this. You wrote:
But, once our Custom VPN app is running the Primary is now the VPN TUN
Right.
instead of the Cellular interface, which we need to pass data
But inside your packet tunnel provider NECP should prevent you from accessing your VPN interface, and thus your data should run over WWAN. Is that not working in general? Or not working solely in the CarPlay case?
If you’re not familiar with NECP, I link to a post that discusses it in Extra-ordinary Networking.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
We are grabbing the dict from State:/Network/Interface/<ifname>/AirPort
and looking at the key WifiNetworkType if that makes sense.
But inside your packet tunnel provider NECP should prevent you from accessing your VPN interface, and thus your data should run over WWAN. Is that not working in general? Or not working solely in the CarPlay case?
The issue is only when connected to CarPlay.
The data comes into the PTP and since it's a Custom VPN application we essentially intercept the data to do our Custom VPN "magic" and then we send it out the WWAN afterwards. The issue is knowing what interface the WWAN is to send it out on and to not select the Wifi since it's an ACTIVE interface but being used for CarPlay. The other piece is that if Wifi and Cellular are both ACTIVE we give preference to Wifi. I don't know what more I can say but hope that makes sense. I'll also take a look at your post on networking
We are grabbing the dict from State:/Network/Interface/<ifname>/AirPort
From System Configuration framework’s dynamic store? How are you accessing that on iOS?
This is iOS, right? I mean, you’re talking about CarPlay and cellular, which AFAIK are iOS-only features, but I wanna be 100% sure.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"