Posts

Post not yet marked as solved
1 Replies
460 Views
I recently updated to macOS Sonoma 14.4 and now UIDevice.current.batteryLevel is always 0. Code to reproduce: import SwiftUI struct ContentView: View { @State private var monitoringEnabled = UIDevice.current.isBatteryMonitoringEnabled; @State private var batteryLevel = UIDevice.current.batteryLevel; var body: some View { VStack { Text("Battery Monitoring Enabled: " + String(monitoringEnabled)) Text("Battery Level: " + String(batteryLevel)) Button("Toggle Monitoring") { monitoringEnabled = !monitoringEnabled; UIDevice.current.isBatteryMonitoringEnabled = monitoringEnabled; batteryLevel = UIDevice.current.batteryLevel; } } .padding() } } Run the above on a macOS 14.4 target, click "Toggle Monitoring", and you'll see battery level is reported as 0: I also see the following error in my app logs when running on macOS 14.4: Error retrieving battery status: result=-536870207 percent=0 hasExternalConnected=1 isCharging=0 isFullyCharged=0 This code displays the expected battery level when running on an actual iOS device:
Posted
by ckarcher.
Last updated
.
Post not yet marked as solved
1 Replies
269 Views
I requested the com.apple.developer.device-information.user-assigned-device-name entitlement on Feb 11 and received an email reply stating "We’ll contact you within a few weeks with your request status." However, it's been more than a month without any updates. Can anyone chime in with their experience RE: how long it took for Apple to review their request for this entitlement? https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_device-information_user-assigned-device-name
Posted
by ckarcher.
Last updated
.