Skip to content

Commit

Permalink
Minor fix to the notification checks
Browse files Browse the repository at this point in the history
To ensure that we don't fail if we have more permissions than requested
e-mission/e-mission-docs#722 (comment)

Without this fix, having sound enabled for app notifications would cause the
checks to fail to fail, since the requested flags = 5 and the actual flags = 7

With this fix, we bitwise and the two values to remove the excess permissions.
7 (111) & 5 (101) = 101 = 5 = requested permissions
  • Loading branch information
shankari committed Apr 27, 2022
1 parent 25e1142 commit d3dbf83
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
id="cordova-plugin-em-datacollection"
version="1.7.1">
version="1.7.2">

<name>DataCollection</name>
<description>Background data collection FTW! This is the part that I really
Expand Down
2 changes: 1 addition & 1 deletion src/ios/Verification/TripDiarySensorControlChecks.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ +(BOOL)checkMotionActivityPermissions {
+(BOOL)checkNotificationsEnabled {
UIUserNotificationSettings* requestedSettings = [self REQUESTED_NOTIFICATION_TYPES];
UIUserNotificationSettings* currSettings = [[UIApplication sharedApplication] currentUserNotificationSettings];
return requestedSettings.types == currSettings.types;
return (currSettings.types & requestedSettings.types) == requestedSettings.types;
}

+(UIUserNotificationSettings*) REQUESTED_NOTIFICATION_TYPES {
Expand Down

0 comments on commit d3dbf83

Please sign in to comment.