NEHotspotConfigurationErrorDomain Code=8 “internal

2019-03-25 02:11发布

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.

7条回答
Animai°情兽
2楼-- · 2019-03-25 02:58

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.

查看更多
登录 后发表回答