问题
I'm creating an app on Swift, and I need to know, if there's any way I can programatically auto connect an iPhone to a WiFi giving as paremeters the SSID and the Password from that WiFi Network.
Thanks in advance.
回答1:
Below code will work on Xcode 9 and iOS 11
let WiFiConfig = NEHotspotConfiguration(ssid: "Mayur1",
passphrase: "123456789",
isWEP: false)
WiFiConfig.joinOnce = false
NEHotspotConfigurationManager.shared.apply(WiFiConfig) { error in
// Handle error or success
print(error?.localizedDescription)
回答2:
Not possible unfortunately! Too many issues that Apple would be not okay with. If you're working with a jailbroken device it may be possible (if it's not going on the app store, either)
Here's a question similar to yours you might want to look at
回答3:
Quotation from Apple Developer Documentation:
The NEHotspotHelper interface allows an app to participate in the process of joining Wi-Fi/hotspot networks. Such an app is referred to as a Hotspot Helper. A Hotspot Helper receives commands to be processed in the background that allow it to participate in the Hotspot Network state machine.
来源:https://stackoverflow.com/questions/35613344/programmatically-auto-connect-to-wifi-ios