我正在嘗試在iOS 9.1下使用BatteryCenter
和私有框架並藉助nst's iOS Runtime Headers。這是出於研究目的,並不會讓它進入AppStore。私有iOS框架返回NULL
這裏有各自的代碼:
- (void)batteryCenter {
NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/BatteryCenter.framework"];
BOOL success = [bundle load];
if(success) {
Class BCBatteryDevice = NSClassFromString(@"BCBatteryDevice");
id si = [[BCBatteryDevice alloc] init];
NSLog(@"Charging: %@", [si valueForKey:@"charging"]);
}
}
- (void)commonUtilities {
NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/CommonUtilities.framework"];
BOOL success = [bundle load];
if(success) {
Class CommonUtilities = NSClassFromString(@"CUTWiFiManager");
id si = [CommonUtilities valueForKey:@"sharedInstance"];
NSLog(@"Is Wi-Fi Enabled: %@", [si valueForKey:@"isWiFiEnabled"]);
NSLog(@"Wi-Fi Scaled RSSI: %@", [si valueForKey:@"wiFiScaledRSSI"]);
NSLog(@"Wi-Fi Scaled RSSI: %@", [si valueForKey:@"lastWiFiPowerInfo"]);
}
}
雖然我得到的類回去,他們所有的尊重數值是NULL這是奇怪的,因爲有些必須是真實的,例如我已連接到Wi-Fi,因此isWiFiEnabled
應該是YES
。
錯過了什麼,我的代碼沒有返回什麼期望?它是否需要權利?如果是這樣的話?