2.4.10 issue of getBatteryLevel on iOS
sianzain opened this issue · comments
sianzain commented
如果ios沒有開啟監控電池
[UIDevice currentDevice].batteryMonitoringEnabled = YES;
取到的 [UIDevice currentDevice].batteryLevel 為 -1
修正代碼如下
CCDevice-ios
float Device::getBatteryLevel()
{
[UIDevice currentDevice].batteryMonitoringEnabled = YES;
return [UIDevice currentDevice].batteryLevel;
}