Auto connect to SSID(WiFi profiled EAP-SIM)

I created and installed wifi profile for EAP SIM. I can connect to respective SSID by manual selection in wifi settings.But I am trying to auto connect to that SSID from my code.I don't want to change any configuration as it is in wifi profile, just want to connect. How far I have tried :


let hotspotEAPSettings = NEHotspotEAPSettings.init()

hotspotEAPSettings.supportedEAPTypes = [18]

let hotspotConfig = NEHotspotConfiguration(ssid: "WiFiCalling", eapSettings: hotspotEAPSettings)

NEHotspotConfigurationManager.shared.apply(hotspotConfig) {[unowned self] (error) in

        if error != nil {
              if error?.localizedDescription == "already associated."
               {
                       print("Connected")
                }
                 else{
                       print("No Connected")
                  }
        }
        else {
               print("Connected")
         }
 }

It is saying :


Error Domain=NEHotspotConfigurationErrorDomain Code=4 "invalid EAP settings." UserInfo={NSLocalizedDescription=invalid EAP settings

If I execute this code

let hotspotConfig = NEHotspotConfiguration(ssid: "WiFiCalling")

NEHotspotConfigurationManager.shared.apply(hotspotConfig) {[unowned self] (error) in

        if error != nil {
              if error?.localizedDescription == "already associated."
               {
                       print("Connected")
                }
                 else{
                       print("No Connected")
                  }
        }
        else {
               print("Connected")
         }
}

It is saying :


Error Domain=NEHotspotConfigurationErrorDomain Code=10 "cannot modify system configuration." UserInfo={NSLocalizedDescription=cannot modify system configuration.


I have searched a lot, spent days on it. But got no proper suggestion for EAP SIM.Thanks to advance.

NOTES: I can auto connect to other wifi except EAP WiFi

Our customer got the same error.

Error Domain=NEHotspotConfigurationErrorDomain Code=10 "cannot modify system configuration." UserInfo={NSLocalizedDescription=cannot modify system configuration.

I would like to know why this happen and how to fix as soon as possible.
Auto connect to SSID(WiFi profiled EAP-SIM)
 
 
Q