如何在iOS中获得广泛的电池信息?

我想知道是否有可能接收有关电池的信息,如:容量(mA),电压(V),iOS内的循环次数?

我知道UIDevice类,但电池水平是不是我正在寻找。

我可能是错误的,但使用公共API这是不可能的。 根据UIDevice文档,看起来你可以做的最多的就是获得电池的充电水平,状态,并启用电池监控。

尝试使用UIDeviceListener ,它基本上从UIDevice窃取整个电池数据字典,而不使用任何私有API。 它暴露了大量的信息:

 { AdapterDetails = { Amperage = 1000; Description = "usb host"; FamilyCode = "-536854528"; PMUConfiguration = 1000; Watts = 5; }; AdapterInfo = 16384; Amperage = 1000; AppleRawCurrentCapacity = 1279; AppleRawMaxCapacity = 1275; AtCriticalLevel = 0; AtWarnLevel = 0; BatteryData = { BatterySerialNumber = REDACTED; ChemID = 355; CycleCount = 524; DesignCapacity = 1420; Flags = 640; FullAvailableCapacity = 1325; ManufactureDate = REDACTED; MaxCapacity = 1273; MfgData = REDACTED; QmaxCell0 = 1350; StateOfCharge = 100; Voltage = 4194; }; BatteryInstalled = 1; BatteryKey = "0003-default"; BootBBCapacity = 52; BootCapacityEstimate = 2; BootVoltage = 3518; CFBundleIdentifier = "com.apple.driver.AppleD1815PMU"; ChargerConfiguration = 990; CurrentCapacity = 1275; CycleCount = 524; DesignCapacity = 1420; ExternalChargeCapable = 1; ExternalConnected = 1; FullyCharged = 1; IOClass = AppleD1815PMUPowerSource; IOFunctionParent64000000 = <>; IOGeneralInterest = "IOCommand is not serializable"; IOInterruptControllers = ( IOInterruptController34000000, IOInterruptController34000000, IOInterruptController34000000, IOInterruptController34000000 ); IOInterruptSpecifiers = ( <03000000>, <26000000>, <04000000>, <24000000> ); IOMatchCategory = AppleD1815PMUPowerSource; IOPowerManagement = { CurrentPowerState = 2; DevicePowerState = 2; MaxPowerState = 2; }; IOProbeScore = 0; IOProviderClass = AppleD1815PMU; InstantAmperage = 0; IsCharging = 0; Location = 0; Manufacturer = A; MaxCapacity = 1275; Model = "0003-A"; Serial = REDACTED; Temperature = 2590; TimeRemaining = 0; UpdateTime = 1461830702; Voltage = 4182; "battery-data" = { "0003-default" = <...>; "0004-default" = <...>; "0005-default" = <...}; "built-in" = 1; } 

它可能使用公共API获取电池容量和电压,并允许在应用程序商店。 链接在这里 –

  1. app store: https : //itunes.apple.com/us/app/system-monitor-ultimate/id740765454?mt = 8
  2. github: https : //github.com/Asido/SystemMonitor 在这里输入图像说明

是的,这是可能的…通过使用私人框架iosDiagnosticsupport.Framework。
经过一些testing,我有一些关于电池的数据,而不是整个日志iDevice。 这里有一些链接可能会帮助你… iOS诊断第3部分

看看JSystemInfoKit库。

你想先导入IOKit框架(从这里获取.framework文件/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/IOKit.framework )和IOKit头文件(从这里获取这些文件)在你的iOS项目。

在这里你可以find你需要使用的方法来获得广泛的电池信息。

另外, IOPSCopyPowerSourcesInfo (来自IOPowerSources.h )返回一个包含电池健康状况等更多信息的NSDictionary。