Reputation: 306
I'm making a game.
If phone's battery under 60%, the yield decrement is 60 - current battery%
So, My question is: Can I get an information about battery % in iOS?
Upvotes: 0
Views: 333
Reputation: 39081
If you wa t to get the Battery charge use this [UIDevice currentDevice].batteryLevel
It will return a float 0.0 - 1.0.
Upvotes: 2
Reputation: 63667
NSArray *stateArray = @[@"Battery state is unknown",
@"Battery is not plugged into a charging source",
@"Battery is charging",
@"Battery state is full"];
NSString *status = [NSString stringWithFormat:@"Battery state: %@, Battery level: %0.2f%%",
stateArray[[UIDevice currentDevice].batteryState],
[UIDevice currentDevice].batteryLevel * 100];
NSLog(@"%@", status);
Upvotes: 2