如何在iOS中获取大量的电池信息? [英] How to obtain extensive battery info in iOS?

查看:236
本文介绍了如何在iOS中获取大量的电池信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以接收有关电池的信息,例如:iOS中的容量(mA),电压(V),周期计数?

I'm wondering is it possible to receive information about battery like: capacity (mA), voltage (V), cycle count within iOS?

我知道UIDevice类,但是电池电量不是我想要的.

I know UIDevice class, but battery level is not what I'm looking for.

推荐答案

我对此可能有误,但使用公共API则无法实现.根据

I might be wrong about this but using public APIs this is not possible. According to the UIDevice documentation, it appears the most you can do is get the battery charge level, its state, and enable battery monitoring.

更新2019年2月15日:看起来像iOS UIDevice API现在允许开发人员访问设备的电池电量级别. !目前,它公开了4种不同的API.从外观上看,它们不是私有"的,换句话说,开发人员可以安全地使用它们,而不会阻止Apple从AppStore阻止您的应用程序.

Update 15th Feb 2019: Looks like iOS UIDevice API's now allow developers to get access to battery charge level for the device. Whooo! It currently exposes 4 different API's. By the looks of it these are not "private", in other words can be used safely by developers without Apple blocking your app from AppStore.

获取设备电池状态

  1. var batteryLevel: Float(设备的电池电量).
  2. var isBatteryMonitoringEnabled: Bool(一个布尔值,指示是否启用(true)或否(false)电池监视).
  3. var batteryState: UIDevice.BatteryState(设备的电池状态).
  4. enum UIDevice.BatteryState(设备的电池电源状态).
  1. var batteryLevel: Float (The battery charge level for the device).
  2. var isBatteryMonitoringEnabled: Bool (A Boolean value indicating whether battery monitoring is enabled (true) or not (false)).
  3. var batteryState: UIDevice.BatteryState (The battery state for the device).
  4. enum UIDevice.BatteryState (The battery power state of the device).

这篇关于如何在iOS中获取大量的电池信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆