Getting Device Battery State iOS

//Get permission for Battery Monitoring[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
UIDevice *myDevice = [UIDevice currentDevice];[myDevice setBatteryMonitoringEnabled:YES];
double batLeft = (float)[myDevice batteryLevel] * 100;
NSLog(@"%.f",batLeft);int d = myDevice.batteryState;
//Returns an Integer Value
//UIDeviceBatteryStateUnknown 0
//UIDeviceBatteryStateUnplugged 1
//UIDeviceBatteryStateCharging 2
//UIDeviceBatteryStateFull…

--

--

--

iOS Developer, Triple graduated, Passionate, Love workout, blogger

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Proving Grounds XposedAPI walkthrough

Python Send mail to multiple accounts using smtplib

Break Time!

Translate German to English text with Deep Learning AI in Python

Role of QA and Automation in DevOps

AWS Cloud and It’s Case Study

Dependent Types: A New Paradigm?

Cover from PragPub Magazine, April 2013

How to Convert ODT to PNG in Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mr.Javed Multani

Mr.Javed Multani

iOS Developer, Triple graduated, Passionate, Love workout, blogger

More from Medium

SwiftUI with Coordinator Flow Controllers

MVVM-C Xcode Template to reduce development time

RxSwift Combination Operators: zip, combineLatest & withLatestFrom

apple/swift-evolution 上關於 guard 的有趣討論