Thank you for the reply.
I was bale to connect to Wi-Fi network programmatically using NEHotspotConfigurationManager(using SSID and Password).
i would also like to know is there a specific function that we can use to connect to Wi-Fi using (SSID,Password and Certificate) in NEHotspotConfigurationManager?
Post
Replies
Boosts
Views
Activity
i tried using NEHotspotEAPSettings in the below code and i and getting some errors.
let eapSettings = NEHotspotEAPSettings()
eapSettings.isTLSClientCertificateRequired = true
eapSettings.ttlsInnerAuthenticationType = .eapttlsInnerAuthenticationEAP
eapSettings.supportedEAPTypes = [NEHotspotEAPSettings.EAPType.EAPTLS.rawValue as NSNumber]
guard let certificateURL = Bundle.main.url(forResource: "certificate-name", withExtension: "crt") else {
print("Certificate file not found.")
return
}
do {
let certificateData = try Data(contentsOf: certificateURL)
eapSettings.setTrustedServerCertificates([certificateData]) //AA
} catch {
print("Failed to load certificate data:", error.localizedDescription)
return
}
configuration = NEHotspotConfiguration(ssid: ssidValue, eapSettings: eapSettings) //BB
NEHotspotConfigurationManager.shared.apply(configuration!) { (error) in
if let error = error {
print("Failed to connect to WiFi network: \(error.localizedDescription)")
} else
print("Successfully connected to WiFi network.")
}
}
Errors:
2023-06-20 17:44:40.079743+0900 [874:203915] [] NEHotspotEAPSettings invalid certificate data type //(comes from AA)
2023-06-20 17:44:40.080467+0900 [874:203915] [] NEHotspotConfiguration identity not provided //(comes from BB)
2023-06-20 17:44:40.080576+0900 [874:203915] [] NEHotspotConfiguration invalid EAP settings. //(comes from BB)
Failed to connect to WiFi network: invalid EAP settings.
i would like to know if there is a specific certificate datatype that needed to use with NEHotspotEAPSettings?
Does this means the bug is fixed in 17.2?
https://developer.apple.com/documentation/safari-release-notes/safari-17_2-release-notes
Fixed a cache miss bug in DOMCache that triggered service worker fetch errors. (115740959) (FB13188943)
I'm also getting the same problem but it's in WKWebView loading Angular App. Does WKWebView problem also going to be fixed from above bug fix in 17.2?
I mad a mistake and this phenomenon is happening in iPad 10th generation and iPad OS is ** 17.2 **.
Environment: ・Device: iPad 10th generation ・OS:iPad OS 17.2 ・Native App : Swift 5
Thank you for the reply. I was able to connect using the above flow that motioned. Now i'm trying to handle the error in the code.When i try even OS Dialog showing with "Cannot connect" response return as Success.
https://forums.developer.apple.com/forums/thread/96834?page=2
I read the above thread and what i can understand from that is it's a bug in the os method. So does this problem fixed on latest iOS version? or is there a way to handle this problem?
I wrote my error handling code bellow→
NEHotspotConfigurationManager.shared.removeConfiguration(forSSID: self.ssid)
let hotspotConfiguration = NEHotspotConfiguration(ssid: self.ssid, eapSettings: eapSetting)
manager.apply(hotspotConfiguration){ (error) in
if let error = error {
print("Error")
return
} else {
print("Success")
return
}
}
Thank you for the quick reply, Yeah previous thread is really old. So i made a new one with same topic, subtopic, and tags.
New thread: https://developer.apple.com/forums/thread/765186
Thank you for details and explanation.
[quote='806989022, DTS Engineer, /thread/765186?answerId=806989022#806989022']
What sort of network requires you to set these parameters?
[/quote]
Actually it is a private network and to connect with this private network i need to setup all IP Address, SubNetMask, Router and DNS server address.
[quote='806989022, DTS Engineer, /thread/765186?answerId=806989022#806989022']
You can monitor the current networking state to see if the join request was successful.
[/quote]
Like you suggested i already tried with monitoring the current connected Wifi SSID using the below code. So then i can figure the connected and not connected status correctly.
let eapSetting = NEHotspotEAPSettings()
eapSetting.username = self.username
eapSetting.password = self.password
eapSetting.supportedEAPTypes = [NEHotspotEAPSettings.EAPType.EAPPEAP.rawValue as NSNumber]
eapSetting.trustedServerNames = ["ABC"]
NEHotspotConfigurationManager.shared.removeConfiguration(forSSID: self.ssid)
let hotspotConfiguration = NEHotspotConfiguration(ssid: self.ssid, eapSettings: eapSetting)
manager.apply(hotspotConfiguration){ (error) in
if self.currentSSIDs().first == self.ssid {
print("Success")
return
} else {
print("Error")
return
}
}
func currentSSIDs() -> [String] {
guard let interfaceNames = CNCopySupportedInterfaces() as? [String] else {
return []
}
return interfaceNames.flatMap { name in
guard let info = CNCopyCurrentNetworkInfo(name as! CFString) as? [String:AnyObject] else {
return nil
}
guard let ssid = info[kCNNetworkInfoKeySSID as String] as? String else {
return nil
}
return ssid
}
}
I only need to test it for three cases,
Wrong SSID
Wrong UserName
Wrong Password
when i test for above test cases output from currentSSIDs() method is like below,
Wrong SSID → []
Wrong UserName → []
Wrong Password → ["SSID1"]
if currentSSIDs() method's output is like [] for above three case i was able to handle my error part without problem. But for Wrong Password it is return as connected. So i would like to know whether my code is wrong or is there a another way to catch these three cases?
[quote='807167022, DTS Engineer, /thread/765186?answerId=807167022#807167022']
I think you’ll have to look at the network side of this.
[/quote]
Oh really, i will ask this from the network side.
But the thing is OS related dialog box returning from NEHotspotConfigurationManager apply method with "Cannot Connect to ABCWiFi" is showing. So i'm a bit confused with the result of currentSSIDs() method. is there any explanation for this from iOS ?