[英]UIDeviceListener not working in iOS 10
我正在使用UIDeviceListener-master( https://github.com/eldade/UIDeviceListener )類來獲取batteryCount,batterymaximumCapacity,但從未調用其listner類。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(listenerDataUpdated:) name: kUIDeviceListenerNewDataNotification object:nil];
請提供有關在iOS10中獲取電池詳細信息的解決方案。
它無法在iOS10上運行,您可以在UIDeviceListener Github問題上找到更多信息https://github.com/eldade/UIDeviceListener/issues/3
您可以使用IOKit:
mach_port_t iokitPort = 0;
CFMutableDictionaryRef properties;
IOMasterPort(0, &iokitPort);
CFDictionaryRef serviceName = IOServiceNameMatching("AppleARMPMUCharger");
io_service_t service = IOServiceGetMatchingService(iokitPort, serviceName);
if (service == 0)
return nil;
kern_return_t status = IORegistryEntryCreateCFProperties(service,
&properties,
kCFAllocatorDefault,
kNilOptions);
IOObjectRelease(service);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.