Battery level getting from UIDevice is not accurate on iOS17

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?

Battery level reporting is as accurate as it is intended to be.

We also handle battery information in our app, and it's crucial to find a solution if we cannot retrieve it at the 1% level, as it might cause user anxiety...

This has changed in the past; in 2013 it had a resolution of 5%. (Does it depend on the device?)

I wasn't aware that it had changed to 1% at some point, but it does seem to be 1% on my current iOS 16 devices. I guess reducing it to 5% is another anti-fingerprinting measure.

Back in 2013 I asked for the API to report what rounding it was applying. My requirement was to let the user choose a battery level at which the app would stop doing some background activity. If the user chooses e.g. 2% but the reported value jumps from 5% to 0%, that's not a great user experience. So I wanted to have my slider jump in the same resolution steps as the reported values.

Of course the suggestion got zero replies from Apple, as usual.

Hi, No matter how hard you try, it still doesn't work?

+1 Here, Please fix it apple.

Same issue. Please fix it Apple.

+1 Please fix it

+1 Please fix.

+1. Please fix it. Thx

+1 Please Fix!

+1 Please Fix!

+1 Please Fix!

+1 Please Fix!

Apple DTS Engineer answer : The battery level API is returning the values it is expected to return. The API does not specify the degree to which the battery level value is rounded. As you found, on some iOS versions, it is rounded to 1%, and on other iOS versions, it is rounded to 5%. There is no other code you can use to change this degree of rounding. 😤

I agree that this is problematic for users who expect to see an accurate battery level yet it differs from what is shown on screen leading to complaints of accuracy but it seems this is out of our control.

@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.

Battery level getting from UIDevice is not accurate on iOS17
 
 
Q