【发布时间】:2018-02-09 21:55:25
【问题描述】:
我正在尝试让我的移动应用程序连接到 Wifi 网络(出于配置目的)。从 iOS 11 开始,这应该可以通过 NEHotspotConfiguration 和 NEHotspotConfigurationManager 类实现。
问题是我不断收到内部错误(错误代码 8),并且我没有收到用户提示请求连接到 wifi 网络的权限。我已经在 Xcode 中设置了 NEHotspotConfigurationManager 类所需的热点配置功能。另外值得一提的是,我只在真机上进行测试,因为 iOS 模拟器不支持 wifi。
虽然我使用的是 NativeScript 框架,但似乎这更多的是底层 iOS 平台的问题。
到目前为止,我有这个代码:
this.wifiManager = NEHotspotConfigurationManager.new();
this.wifiConfig = NEHotspotConfiguration.alloc().initWithSSID(this.config.wifi.SSID);
this.wifiConfig.joinOnce = true;
this.wifiManager.applyConfigurationCompletionHandler(this.wifiConfig, (error: NSError) => {
if (error && error.code!==NEHotspotConfigurationError.AlreadyAssociated) {
console.log(`wifiManager.applyConfigurationCompletionHandler error code ${error.code}: ${error.localizedDescription}`);
} else {
console.log(`wifiManager.applyConfigurationCompletionHandler success!`);
}
});
提前致谢!
附:这个post 表明这可能只是设备本身的问题,设备重启应该可以解决问题,但对我来说不是这样
【问题讨论】:
-
有什么更新吗?我也有同样的问题
标签: ios nativescript