How can I obtain the temperature of the Battery in IOS programatically. Also are there any API's in IOS that would give us any information on the Battery Manufacturer etc. Currently I am able to obtain the Battery level and charging status . Wanted to check if there is any other Battery related information that we can obtain in IOS
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
That is not possible in the public API.
As @Fogh correctly indicated, that isn't possible using the public API. The data is available in
IOKit
, butIOKit
is considered a private framework on iOS. If you're developing for in-house distribution, just useIOKit
(here's an example program that shows how to get the data: https://github.com/eldoogy/EEIOKitListener)If you're more adventurous and would like to somehow get this data in an App Store app, you can use a class I wrote called
UIDeviceListener
that basically steals the data from the system without relying on any private APIs, but I cannot promise you that Apple will approve it... https://github.com/eldoogy/UIDeviceListenerRegardless of which approach you use, you will end up with a dictionary that contains a key called
Temperature
, which is an integer representing battery temperature in Celsius (divide by 100 into afloat
to get an accurate value).The manufacturer information could be hosted on your server and you just detect the device running your app, fetch the battery stats, parse and display.
For the battery temperature, if there are no APIs for it I guess that its an approximation using the current CPU usage and GPU usage or something?