iOS 12 - 获取iPhone电池周期数的最简单方法

问题描述 投票:2回答:1

我知道目前公共API只允许获得两个有用的电池属性:batteryLevelbatteryState。即使在2018年WWDC之后也没有任何变化。

let batteryLevel = UIDevice.current.batteryLevel  /* from 0 to 1 */
let batteryState = UIDevice.current.batteryState  /* four states */

使用免费的私有API或Apple的官方API,在iOS 12中获取电池循环次数的最简单方法是什么?

附: UIDeviceListener在iOS 10/11/12中无效。它也是用Objective-C编写的。

swift swift4 battery ios12
1个回答
1
投票

自从iOS 10发布以来,Apple已经切断了对App Store中第三方应用程序的电池详细信息的访问权限,使这些应用程序完全无用。

目前在iOS 12中无法使用公共API获取iPhone的battery cycle count。甚至macOS Mojave 10.14中的Console应用程序也没有显示iPhone的循环计数。

因此,查看循环计数的唯一可靠方法是安装coconutBattery macOS应用程序。

enter image description here

附: UIDeviceListener在iOS 10及更高版本(read this SO post)中不起作用。

© www.soinside.com 2019 - 2024. All rights reserved.