我正在研究一些不需要在App Store上的東西,所以我沒有使用私有API來滿足我的需求的問題 我正在嘗試使用MobileWiFi. framework to read the RSSI value for the wireless network the phone is currently connected to. I've included the
https://github.com/Cykey/ios-reversed-headers/tree/c613e45f3ee5ad9f85ec7d43906cf69ee812ec6a/MobileWiFi`標題並使用橋接標題將它們包含在我的swift項目中,並按如下所示編寫代碼。請原諒我,我是一個新手。使用私有API讀取WiFi RSSI值
import SystemConfiguration.CaptiveNetwork
typealias _WiFiManagerClientCreate = @convention(c) (CFAllocator, CInt) -> UnsafeRawPointer
typealias _WiFiManagerClientCopyDevices = @convention(c) (UnsafeRawPointer) -> CFArray
typealias _WiFiDeviceClientCopyProperty = @convention(c) (UnsafeRawPointer, CFString) -> CFPropertyList
if let libHandle = dlopen (Paths.ipConfiguration, RTLD_LAZY) {
result = libHandle.debugDescription
let _createManagerPtr = dlsym(libHandle, "WiFiManagerClientCreate")
let _clientCopyDevicesPtr = dlsym(libHandle, "WiFiManagerClientCopyDevices")
let _clientCopyPropertyPtr = dlsym(libHandle, "WiFiDeviceClientCopyProperty")
if (_createManagerPtr != nil) && (_clientCopyDevicesPtr != nil) && (_clientCopyPropertyPtr != nil) {
let _createManager = unsafeBitCast(_createManagerPtr, to: _WiFiManagerClientCreate.self)
let _clientCopyDevices = unsafeBitCast(_clientCopyDevicesPtr, to: _WiFiManagerClientCopyDevices.self)
let _clientCopyProperty = unsafeBitCast(_clientCopyPropertyPtr, to: _WiFiDeviceClientCopyProperty.self)
let manager = _createManager(kCFAllocatorDefault, 0)
let devices = _clientCopyDevices(manager)
let client = CFArrayGetValueAtIndex(devices, 0)
let data = _clientCopyProperty(client!, "RSSI" as CFString)
let rssi = CFDictionaryGetValue(data as! CFDictionary, "RSSI_CTL_AGR")
NSLog("RSSI: \(rssi)")
}
dlclose(libHandle)
}
這會產生錯誤fatal error: unexpectedly found nil while unwrapping an Optional value which stems from trying to call _createManager
我設法讓代碼來構建的,但現在看來似乎不起作用,因爲的權利需要,應該一個越獄的手機 –
上工作,它在非工作越獄設備? – user2323838
不,因爲您無法獲得運行所需的權利 –