eldade / UIDeviceListener

Obtain power information (battery health, charger details) for iOS without any private APIs.
GNU General Public License v3.0
240 stars 38 forks source link

I have iOS 11.3 and no data is showing? #9

Open danylokiz opened 6 years ago

danylokiz commented 6 years ago

I'm running an app on iPhone 5s and my iOS is 11.3. So, this is what is get:

batteryDesignCapacity=0 batteryCycleCount=0 batteryMaximumCapacity=0 batteryHealth=1.000000 batteryRawBatteryLevel=1.000000 voltage=0.000000 isPluggedIn=0 isCharging=0 isFullyCharged=0 batteryTemperature=0.000000 adapterAmperage=0 adapterWattage=0 chargerConfiguration=0 chargingAmperage=0 dischargeAmperage=0 devicePowerConsumption=0.000000

Does anybody know how to solve it?

mice007 commented 6 years ago

It won't work after iOS 10

danylokiz commented 6 years ago

@mice007 Ok, so what can I use instead of it? Maybe, You know? I wanna to receive result like with this app.

mice007 commented 6 years ago

At the moment, nothing, so far. I don't know any ways to get battery details which is "Apple Friendly" so you can upload to the store.

danylokiz commented 6 years ago

@mice007 Hmm, "Apple Friendly" what do You mean?

mice007 commented 6 years ago

I mean a code which can be uploaded to the App Store without getting your ass kicked out of there.

danylokiz commented 6 years ago

So, I can't use like another api, yes?

danylokiz commented 6 years ago

But I saw other apps in the App Store, which work nice and they're still there

mice007 commented 6 years ago

the problem is there is no public API or anything documented (SDK) by Apple about this. You cannot use private API in the store.

mice007 commented 6 years ago

Not for long, i quess

danylokiz commented 6 years ago

But, what API that apps use?

eldade commented 6 years ago

@danylokiz Could you please provide the names of some of those apps that are still working?

danylokiz commented 6 years ago

@eldade Sure, for example, Battery Life, Battery Saver...

eldade commented 6 years ago

@danylokiz As far as I can tell, Battery Saver only shows current charge state (same as what you get on the status bar), but really nothing else. Battery Life is directly calling IOKit to get the data. You can check out a sample I have at https://github.com/eldade/EEIOKitListener to see what kind of data they're getting.

Here's the difference: rather than directly calling IOKit the way my sample does it, they are doing run-time linking to avoid detection. For example, instead of directly calling something like IORegistryEntryCreateCFProperties, they are using dlsym() to look the symbol up in runtime and then they just call it.

danylokiz commented 6 years ago

Is it possible to do something for iOS like CoconutBattery for macOS?

eldade commented 6 years ago

By the way, since iOS 10 (I think), Apple has dramatically reduced the info available from the IOKit PMU charger dictionary. Nowadays it looks like this:

{
    AdapterInfo = 16384;
    AtCriticalLevel = 0;
    BatteryInstalled = 1;
    CurrentCapacity = 2240;
    ExternalChargeCapable = 1;
    ExternalConnected = 1;
    FullyCharged = 0;
    IOClass = AppleARMPMUCharger;
    IsCharging = 1;
    MaxCapacity = 2800;
    Voltage = 4085;
}
danylokiz commented 6 years ago

Is it possible to find out the temperature of the battery and cycle count?

bill350 commented 6 years ago

@danylokiz @eldade did you find any ways to get the battery health since the recent restrictions? I'm curious about the dlsym() runtime technic if you have any resources about it.

Moreover, it seems that the list was completely killed by iOS 12 too: https://github.com/eldade/EEIOKitListener/issues/2