16

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.

Yason Din'Alt
  • 163
  • 1
  • 9

8 Answers8

10

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...

Julien
  • 116
  • 1
  • 6
  • Any updates? I have the same issue - after a while i get internal error and my capabilities are on – ironRoei Dec 05 '18 at 11:04
  • 2
    This is supposed to be fixed in iOS 12.2 according to eskimo. src: https://forums.developer.apple.com/thread/107851 – MikeB Mar 27 '19 at 08:42
  • if you still facing this issue follow the below answer of Andreas Netzmann – Sher Ali May 05 '19 at 05:35
  • While this was fixed for some time it is showing up again on iOS 13.3 for us... only restarting the phone helps – Mike Jan 13 '20 at 08:16
5

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.

Xcode Target Capabilities Tab

This did fix the issue for me.

2

I have this internal error issue (on iOS 12.0) and the reproduce steps is as following.

  1. Use NEHotspotConfiguration applyConfiguration API to show a alert prompting user to connect to a WIFI network
  2. Leave that alert for like 3+ minutes then click "connect"

There will be 2 issues occur.

  1. Completion handler of applyConfiguration call won't be called
  2. Every attempts of NEHotspotConfiguration 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.

Egist Li
  • 624
  • 5
  • 9
1

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.

0

I'm having the exact same issue. I've even tried powering the hotspot device wifi off and on (but of course given it's an "internal error" would appear that this is in iOS itself rather than the device).

Does this appear when you're running with the debugger? For me I noticed I had left my iPhone set up for network connectivity to Xcode (Devices window > "Connect via network" checked). Turning this off seemed to make the problem go away.

I'll keep this SO page open in case it comes back and I have to dig in even deeper

anabi
  • 217
  • 3
  • 10
  • I guess you are right and "Connect via network" actually could be a reason for this internal error. Restarting device still should do the trick. – Yason Din'Alt Jan 29 '18 at 13:58
0

I am having the same issue. I try to connect with already connected Wifi the it shows "already associated" else it will show "internal error". I have checked my "Connect via network" is unchecked.

Restarting my phone actually works for me. Sometimes its shows "Unable to connect" but after restart it works fine.

Nupur Gupta
  • 305
  • 1
  • 12
0

In my case this happens only if I try this code on iOS Simulator (that doesn't supporto hotspot capability).

christian mini
  • 1,662
  • 20
  • 39
0

Another scenario for this is if you're trying to connect to the same SSID that's already connected to on the device.

Jasjeev
  • 385
  • 1
  • 4
  • 17