Skip to content

Commit

Permalink
fix: Device charging status is now reported as a boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Macharg committed Apr 21, 2020
1 parent 0a2efd9 commit 5a45951
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ Bugsnag Notifiers on other platforms.
* NSWorkspaceScreenSleep/Wake notifications now use the correct notification center.
(#525)[https://github.com/bugsnag/bugsnag-cocoa/pull/525]

* Device Charging status was being incorrectly reported as a number rather than a boolean.
Device charging status is represented as a four-valued enum. If the device is plugged in it reports
as charging, even if it is at 100%. Any other values are reported as not charging.
(#551)[https://github.com/bugsnag/bugsnag-cocoa/pull/551]

## 5.23.0 (2019-12-10)

This release removes support for reporting 'partial' or 'minimal' crash reports
Expand Down
5 changes: 3 additions & 2 deletions Source/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -968,13 +968,14 @@ - (void)metadataChanged:(BugsnagMetadata *)metadata {
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
- (void)batteryChanged:(NSNotification *)notification {
NSNumber *batteryLevel = @([UIDevice currentDevice].batteryLevel);
NSNumber *charging = @([UIDevice currentDevice].batteryState == UIDeviceBatteryStateCharging);
BOOL charging = [UIDevice currentDevice].batteryState == UIDeviceBatteryStateCharging ||
[UIDevice currentDevice].batteryState == UIDeviceBatteryStateFull;

[[self state] addMetadata:batteryLevel
withKey:BSGKeyBatteryLevel
toSection:BSGKeyDeviceState];

[[self state] addMetadata:charging
[[self state] addMetadata:charging ? @YES : @NO
withKey:BSGKeyCharging
toSection:BSGKeyDeviceState];
}
Expand Down

0 comments on commit 5a45951

Please sign in to comment.