В iOS, когда мы читаем, SSID становится нулевым или пустым?IOS

Программируем под IOS
Anonymous
В iOS, когда мы читаем, SSID становится нулевым или пустым?

Сообщение Anonymous »

Существующий код до iOS 26 работал хорошо, но начиная с iOS 26 получает нулевые/пустые данные ssid.
Мой старый код для iOS 26 ниже –
func fetchSSIDInfo() -> String {
var currentSSID = ""
if let interfaces = CNCopySupportedInterfaces() {
for i in 0.. String {
// iOS 14+ path (NEHotspotNetwork.fetchCurrent is async callback)
if #available(iOS 14.0, *) {
let sem = DispatchSemaphore(value: 0)
var ssidResult: String?

NEHotspotNetwork.fetchCurrent { network in
if let s = network?.ssid, !s.isEmpty {
ssidResult = s
}
sem.signal()
}

// Wait for the callback (bounded by timeout)
_ = sem.wait(timeout: .now() + timeout)

if let s = ssidResult, !s.isEmpty {
return s
}

// If NEHotspotNetwork didn't return an SSID (or timed out), fall through to CaptiveNetwork fallback.
}

// Fallback for older iOS or if NEHotspotNetwork didn't provide SSID
if let interfaces = CNCopySupportedInterfaces() as? [String] {
for interface in interfaces {
if let info = CNCopyCurrentNetworkInfo(interface as CFString) as? [String: Any],
let ssid = info["SSID"] as? String,
!ssid.isEmpty {
return ssid
}
}
}

return ""
}


Подробнее здесь: https://stackoverflow.com/questions/797 ... l-or-empty

Вернуться в «IOS»