I\'m using this function to get current battery level of device:
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
UIDevice *myDevice = [UIDevice c
If you are using swift 5.1 or greater this code will definitely work for you.
Step 1:- To get started, first enable the isBatteryMonitoringEnabled property of the current device, like this:-
UIDevice.current.isBatteryMonitoringEnabled = true
Step 2:- You can now read the current battery level
let level = UIDevice.current.batteryLevel
print(level)