meaton, thank you for your response.
I tried a Wifi connection using NEHotspotConfiguration. However, I did not get the results I wanted.
Please give me advice.
I tried the following:
1. I prepared an Wifi (WPA2).
2. I created a Configuration Profile to connect to this Wifi and installed it on my iPad.
3. I have confirmed that the iPad can connect to this Wifi manually without entering a passphrase. Later, I disconnected this Wifi.
4. I made a program to connect to this Wifi only by SSID.
However, I could not connect to the Wifi using this program.
The code at that time.
@objc(connectWifi:) public func connectWifi(_ command: CDVInvokedUrlCommand) {
if #available(iOS 11.0, *) {
let configuration = NEHotspotConfiguration.init(ssid: "HW01L-50ABD5")
NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
if (error == nil) {
print("success")
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "OK")
self.commandDelegate.send(result, callbackId: command.callbackId)
} else {
print("error")
let result = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAs: error?.localizedDescription)
self.commandDelegate.send(result, callbackId: command.callbackId)
}
}
} else {
}
}
I experimented with:
5. I made a program to connect to Wifi with SSID and passphrase.
However, the iPad did not connect to Wifi.
6. I have deleted the Configuration Profile from this iPad.
7. I ran the program created in '5'.
iPad connected to this Wifi.
The code at that time.
@objc(connectWifi:) public func connectWifi(_ command: CDVInvokedUrlCommand) {
if #available(iOS 11.0, *) {
let configuration = NEHotspotConfiguration.init(ssid: "HW01L-50ABD5", passphrase: "XXXXXXXX", isWEP: false)
NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
if (error == nil) {
print("success")
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: "OK")
self.commandDelegate.send(result, callbackId: command.callbackId)
} else {
print("error")
let result = CDVPluginResult(status: CDVCommandStatus_ERROR, messageAs: error?.localizedDescription)
self.commandDelegate.send(result, callbackId: command.callbackId)
}
}
} else {
}
}
I cannot include the passphrase in programs I make.
What API can I use to connect to Wifi defined in the configuration profile?