NEHotspotConfigurationErrorDomain 代码=8 "internal error."

NEHotspotConfigurationErrorDomain Code=8 "internal error."

我在 iOS 11 iPhone 上使用 NEHotspotConfigurationManager 连接到特定的 Wi-Fi 点,然后断开连接。

代码如下:

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];
        }

我使用了applyConfiguration,一切正常,每次我想应用WiFi配置时,都会出现提示用户连接特定网络的警报,但现在什么也没有,我在 completionHanlder 中收到此错误:

NEHotspotConfigurationErrorDomain Code=8 "internal error."

我稍后在代码中使用了删除配置,但似乎效果不佳:

[[NEHotspotConfigurationManager sharedManager] removeConfigurationForSSID:self.specififcWiFiSSID];

问题是:发生了什么事?为什么它停止提示我加入WiFi网络,还有这个错误是什么意思?

已更新:这似乎是 iOS 本身的错误,重启设备可能会有所帮助。目前更新后一切正常。

目前,只有重新启动设备才能解决问题一段时间,然后再次发生。

完整日志: Domain=NEHotspotConfigurationErrorDomain Code=8 "internal error." UserInfo={NSLocalizedDescription=internal error.}

我试过每次调用 NEHotspotConfigurationManager.shared.removeConfiguration(forSSID: ssid),然后再调用:

let hotspot = NEHotspotConfiguration(ssid: ssid, passphrase: pwd, isWEP: false)
hotspot.joinOnce = true
NEHotspotConfigurationManager.shared.apply(hotspot) { (error) in
    completionHandler?(error)
}

但是问题还是出现了...

我遇到了完全相同的问题。我什至尝试过关闭和打开热点设备 wifi(当然,考虑到它是一个 "internal error",这似乎是在 iOS 本身而不是设备中)。

当您 运行 调试器时会出现这种情况吗?对我来说,我注意到我已经将 iPhone 设置为 Xcode 的网络连接(设备 window > "Connect via network" 已选中)。关闭它似乎可以解决问题。

我会保持这个 SO 页面打开,以防它回来,我不得不深入挖掘

我遇到了同样的问题。我尝试连接已连接的 Wifi,它显示 "already associated",否则它会显示 "internal error"。我检查过我的 "Connect via network" 未选中。

重新启动我的 phone 实际上对我有用。有时它显示 "Unable to connect" 但重启后它工作正常。

如果您仍然遇到这种情况。确保将 HotSpot Capability 添加到您正在使用的 AppID,同时将其添加到 Xcode Target Capabilities 配置选项卡中,并确保 link NetworkExtensions.framework.

这确实解决了我的问题。

我有这个内部错误问题(在 iOS 12.0 上),重现步骤如下。

  1. 使用 NEHotspotConfiguration applyConfiguration API 显示提示用户连接到 WIFI 网络的警报
  2. 将警报保留 3 分钟以上,然后单击 "connect"

会出现 2 个问题。

  1. 不会调用 applyConfiguration 调用的完成处理程序
  2. 每次尝试 NEHotspotConfiguration applyConfiguration 调用都会失败,之后 internal error

遗憾的是,我们发现解决此问题的方法是按照先前答案的建议重新启动设备。只是为了给开发人员提供另一个原因来解决这个问题并且不知道可能是什么原因造成的。

我遇到了同样的问题。现在我使用下一个逻辑: 通话前

    [[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError *error){ ... }

我检查此配置是否已应用,如果是 - 将其删除。

    [[NEHotspotConfigurationManager sharedManager] getConfiguredSSIDsWithCompletionHandler:^(NSArray<NSString *> * _Nonnull wifiList) {

    if ([wifiList containsObject:ssidToConnect])
    {
       [[NEHotspotConfigurationManager sharedManager] removeConfigurationForSSID:containsObject:ssidToConnect];
    }


    [[NEHotspotConfigurationManager sharedManager] applyConfiguration:configuration completionHandler:^(NSError *error){
            completion();
    }}];        

对我来说它适用于 iOS 12.1.4.

就我而言,只有当我在 iOS 模拟器(不支持热点功能)上尝试此代码时才会发生这种情况。

另一种情况是,如果您尝试连接到设备上已连接的同一个 SSID。