I'm using NEHotspotConfigurationManager
with on iOS 11 iPhone
to connect to specific Wi-Fi spot and then disconnect from it.
Here is the code:
if (@available(iOS 11.0, *)) {
NEHotspotConfiguration *configuration = [[NEHotspotConfiguration
alloc] initWithSSID:self.specififcWiFiSSID passphrase:self.specififcWiFiPassword isWEP:NO];
configuration.joinOnce = YES;
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError * _Nullable error) {
NSLog(@"Error : %@",error.description);
}];
} else {
[Router showOfflineMessage:message];
}
I used applyConfiguration and everything was fine, every time I want to apply WiFi configuration, an alert appears that prompts a user to connect specific network, but nothing appears now and I receiving this error in completionHanlder:
NEHotspotConfigurationErrorDomain Code=8 "internal error."
I'm using remove configuration later in code, but it seems not work as well:
[[NEHotspotConfigurationManager sharedManager] removeConfigurationForSSID:self.specififcWiFiSSID];
Question is: what happened? Why it stopped prompts me to join WiFi network, and also what does this error mean?
UPDATED : It seems it was a bug with iOS itself, restart device could help. Currently after updates all works.
For now, only a restart of the device fixes the issue for some time and then it happens again.
Full log:
Domain=NEHotspotConfigurationErrorDomain Code=8 "internal error." UserInfo={NSLocalizedDescription=internal error.}
I've tried calling NEHotspotConfigurationManager.shared.removeConfiguration(forSSID: ssid)
each time before calling:
let hotspot = NEHotspotConfiguration(ssid: ssid, passphrase: pwd, isWEP: false)
hotspot.joinOnce = true
NEHotspotConfigurationManager.shared.apply(hotspot) { (error) in
completionHandler?(error)
}
But the issue still happens...
If you are still experiencing this. Make sure to add the HotSpot Capability to the AppID you are using, also add it in the Xcode Target Capabilities configuration tab and make sure to link the NetworkExtensions.framework.
This did fix the issue for me.
I have this internal error issue (on iOS 12.0) and the reproduce steps is as following.
NEHotspotConfiguration applyConfiguration
API to show a alert prompting user to connect to a WIFI networkThere will be 2 issues occur.
applyConfiguration
call won't be calledNEHotspotConfiguration applyConfiguration
call fails with internal error
afterwards.Sadly the way to fix this we found is to restart the device as suggested by previous answers. Just to provide another reason for developers stuck at this problem and have no idea what might be the cause of this.
I had the same issue. Now I use the next logic: Before call
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError *error){ ... }
I check whether this configuration was applied earlier, and if yes - remove it.
[[NEHotspotConfigurationManager sharedManager] getConfiguredSSIDsWithCompletionHandler:^(NSArray<NSString *> * _Nonnull wifiList) {
if ([wifiList containsObject:ssidToConnect])
{
[[NEHotspotConfigurationManager sharedManager] removeConfigurationForSSID:containsObject:ssidToConnect];
}
[[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError *error){
completion();
}}];
For me it works on iOS 12.1.4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With