How to get real time battery level on iOS with a 1% granularity

后端 未结 7 1725
清酒与你
清酒与你 2020-12-05 03:19

I\'m using this function to get current battery level of device:

[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
UIDevice *myDevice = [UIDevice c         


        
7条回答
  •  独厮守ぢ
    2020-12-05 03:56

    Swift version to get the battery level:

    UIDevice.current.isBatteryMonitoringEnabled = true
    let batteryLevel = UIDevice.current.batteryLevel 
    

    batteryLevel return 0,39; 0,40 values for me.

提交回复
热议问题