Skip to content

Commit

Permalink
[ios] Only save permissions that are expected to be scoped
Browse files Browse the repository at this point in the history
  • Loading branch information
sjchmiela committed May 27, 2020
1 parent 3ed48ee commit 4a87bc1
Showing 1 changed file with 11 additions and 5 deletions.
Expand Up @@ -70,7 +70,10 @@ - (void)askForPermissionUsingRequesterClass:(Class)requesterClass
// ask for permission. If granted then save it as scope permission
void (^customOnResults)(NSDictionary *) = ^(NSDictionary *permission){
UM_ENSURE_STRONGIFY(self)
[self.permissionsService savePermission:permission ofType:permissionType forExperience:self.experienceId];
// if permission should be scoped save it
if ([self shouldVerifyScopedPermission:permissionType]) {
[self.permissionsService savePermission:permission ofType:permissionType forExperience:self.experienceId];
}
resolve(permission);
};

Expand All @@ -82,10 +85,13 @@ - (void)askForPermissionUsingRequesterClass:(Class)requesterClass
UIAlertAction *allowAction = [UIAlertAction actionWithTitle:@"Allow" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
UM_ENSURE_STRONGIFY(self);
NSMutableDictionary *permission = [globalPermissions mutableCopy];
// try to save scoped permissions - if fails than permission is denied
if (![self.permissionsService savePermission:permission ofType:permissionType forExperience:self.experienceId]) {
permission[@"status"] = [[self class] permissionStringForStatus:UMPermissionStatusDenied];
permission[@"granted"] = @(NO);
// if permission should be scoped
if ([self shouldVerifyScopedPermission:permissionType]) {
// try to save scoped permissions - if fails than permission is denied
if (![self.permissionsService savePermission:permission ofType:permissionType forExperience:self.experienceId]) {
permission[@"status"] = [[self class] permissionStringForStatus:UMPermissionStatusDenied];
permission[@"granted"] = @(NO);
}
}
resolve(permission);
}];
Expand Down

0 comments on commit 4a87bc1

Please sign in to comment.