Hi,
I have implemented a check in my app to test if the user is currently connected to a network using the following function:
private func getWiFiSsid()->Bool {
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
m_ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
return true;
}
}
}
return false
}What I need is a function that can determine if Wi-Fi is enabled. regardless if the user is connected to a network or not.
Is this possible?
Thank you in advance
Is there a third party API available that would allow this?
Any third-party API would have to be based on an Apple API, and I’ve already ruled that out.
mainly because without Wi-Fi the app would be unable to accomplish its goal of transmitting data to the device.
What device are we talking about? Another iOS device? Or some sort of Wi-Fi based accessory?
In the iOS/iOS case, there’s nothing to stop the two devices talking over Ethernet. In the iOS/Wi-Fi accessory case, that still might work if you have a Wi-Fi to Ethernet bridge (as I do on my home network).
I’m not claiming that there are no apps with this requirement, but rather my claim is that most folks who ask about this haven’t considered all the edge cases. If you can elaborate more about your specific requirements, I’m happy to discuss them, but right now you’re making a bold claim without offering any context for that.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"