我想要开发一个iOS应用程序,不断接收二进制数据,我需要传输它在应用程序生动显示。
通过googling,我收到了以下代码来建立连接:
let configuration = NEHotspotConfiguration.init(ssid: "SSID Name", passphrase: "12345678", isWEP: false)
configuration.joinOnce = true
NEHotspotConfigurationManager.shared.apply(configuration) { (error) in
if error != nil {
if error?.localizedDescription == "already associated."
{
self.connectionLabel.text = "Connected"
}
else{
self.connectionLabel.text = "Not Connected"
}
}
else {
self.connectionLabel.text = "Connected"
}
}`问题:
在回答时,请注意,我是iOS网络应用程序的新手。
发布于 2018-10-26 09:08:37
应用程序断开,因为您已经将joinOnce设置为true。根据苹果公司的文件:
当joinOnce设置为true时,只要配置它的应用程序在前台运行,热点就会保持配置和连接。当发生下列任何事件时,热点将被断开连接并移除其配置:
若要从配置有joinOnce设置为true的热点断开设备,请调用removeConfiguration(forSSID:)。
如果要连接到该网络,请忽略joinOnce & lifeTimeInDays属性(不要设置)。
https://stackoverflow.com/questions/53004409
复制相似问题