On iOS17, UIDevice.current.batteryLevel is returning values rounded to 0.05, such as 1, 0.95, 0.9. Which used to be a 1% granularity in iOS16. Is this a bug or a new feature?
How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here
Battery level getting from UIDevice is not accurate on iOS17
@Frameworks Engineer It looks like this is not working at all on MacCatalyst builds. I'm consistently getting batteryLevel: 0 and the following error printed to console while debugging:
Error retrieving battery status: result=-536870207 percent=-2109898751 hasExternalConnected=0 isCharging=4 isFullyCharged=244
Is this also intended behavior? We're depending on this value while in fullscreen mode for our users to have a semi-accurate representation of their battery life, specifically for MacBook users.
They broke it in iOS 17, trying to "optimize" battery usage by other apps, etc...
The API does not specify the degree to which the battery level value is rounded.
Indeed. However, it would be reasonable for the documentation to acknowledge that some level of rounding occurs. If you’d like to see that, I recommend that you file a bug against the documentation for the batteryLevel
property
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"