Is there any reliable way to check for an active VPN connection or a connection over Personal Hotspot?
I am currently building an app that uses MultipeerConnectivity for peer-to-peer communication and from what I have learned so far MPC does not work with VPN / Personal Hotspot turned on.
To provide a first-class user experience (and tackle VPN problems in App Review) I want to check for a VPN / Personal Hotspot connection and display the user an alert encouraging him to disable the corresponding connection.
Just like AirDrop which should work quite similar to MPC.
I found this code snippet on Stackoverflow but since I do not really now anything about network interfaces in iOS I came here to seek help. :)
I am currently building an app that uses MultipeerConnectivity for peer-to-peer communication and from what I have learned so far MPC does not work with VPN / Personal Hotspot turned on.
To provide a first-class user experience (and tackle VPN problems in App Review) I want to check for a VPN / Personal Hotspot connection and display the user an alert encouraging him to disable the corresponding connection.
Just like AirDrop which should work quite similar to MPC.
I found this code snippet on Stackoverflow but since I do not really now anything about network interfaces in iOS I came here to seek help. :)
Code Block func isVPNConnected() -> Bool { let cfDict = CFNetworkCopySystemProxySettings() let nsDict = cfDict!.takeRetainedValue() as NSDictionary let keys = nsDict["__SCOPED__"] as! NSDictionary for key: String in keys.allKeys as! [String] { if (key == "tap" key == "tun" key == "ppp" key == "ipsec" key == "ipsec0") { return true } } return false }