Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Round battery level before casting to int
Browse files Browse the repository at this point in the history
  • Loading branch information
friedbunny committed Jan 23, 2016
1 parent e87edeb commit 5a1325d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion platform/ios/src/MGLMapboxEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ - (void) pushEvent:(NSString *)event withAttributes:(MGLMapboxEventAttributes *)
if ( ! [event isEqualToString:MGLEventTypeLocation] && ! [event isEqualToString:MGLEventTypeVisit]) {
[evt setValue:[strongSelf deviceOrientation] forKey:@"orientation"];

[evt setValue:@((int)(100 * [UIDevice currentDevice].batteryLevel)) forKey:@"batteryLevel"];
int batteryLevel = roundf(100 * [UIDevice currentDevice].batteryLevel);
[evt setValue:@(batteryLevel) forKey:@"batteryLevel"];

UIDeviceBatteryState batteryState = [[UIDevice currentDevice] batteryState];
if (batteryState != UIDeviceBatteryStateUnknown) {
Expand Down

0 comments on commit 5a1325d

Please sign in to comment.