2017-07-28 12 views
0

batteryCount、batterymaximumCapacityを取得するためにUIDeviceListener-master(https://github.com/eldade/UIDeviceListener)クラスを使用していますが、そのlistnerクラスは呼び出されません。UIDeviceListenerがiOS 10で動作していません

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(listenerDataUpdated:) name: kUIDeviceListenerNewDataNotification object:nil]; 

バッテリーの詳細をiOS10で取得する方法を教えてください。それはiOS10に取り組んでいない

答えて

0

、あなたはUIDeviceListenerのGithubの詳細については、あなたがIOKitのを使用することができますhttps://github.com/eldade/UIDeviceListener/issues/3

を発行見つけることができます:

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); 
+0

私はIOKitのを使用している場合は、アプリは、AppStoreで拒否されます?? –

+0

それは拒否される可能性がありますはい –

+0

私はバッテリーの状態とバッテリーのパーセンテージをフェッチしたくない、私はちょうどサイクルカウントを取得したい –

関連する問題