Yas*_*Alt 14 objective-c ios networkextension
我使用NEHotspotConfigurationManager
与iOS 11 iPhone
连接到特定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];
}
Run Code Online (Sandbox Code Playgroud)
我使用了applyConfiguration,一切都很好,每次我想应用WiFi配置时,都会出现提示用户连接特定网络的警报,但现在没有任何内容出现,我在completionHanlder中收到此错误:
NEHotspotConfigurationErrorDomain Code=8 "internal error."
Run Code Online (Sandbox Code Playgroud)
我稍后在代码中使用删除配置,但似乎不能正常工作:
[[NEHotspotConfigurationManager sharedManager] removeConfigurationForSSID:self.specififcWiFiSSID];
Run Code Online (Sandbox Code Playgroud)
问题是:发生了什么?为什么它停止提示我加入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)
}
Run Code Online (Sandbox Code Playgroud)
但是问题仍然存在...
如果您仍然遇到这种情况。确保将 HotSpot 功能添加到您正在使用的 AppID 中,同时将其添加到 Xcode 目标功能配置选项卡中,并确保链接 NetworkExtensions.framework。
这确实为我解决了这个问题。
归档时间: |
|
查看次数: |
3376 次 |
最近记录: |