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

Commit

Permalink
Check if NSCameraUsageDescription is set and return error instead of …
Browse files Browse the repository at this point in the history
…crash (#643)
  • Loading branch information
jcesarmobile authored Apr 8, 2018
1 parent a78262b commit e516a87
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ios/CDVBarcodeScanner.mm
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ -(BOOL)notHasPermission
authStatus == AVAuthorizationStatusRestricted);
}

-(BOOL)isUsageDescriptionSet
{
NSDictionary * plist = [[NSBundle mainBundle] infoDictionary];
if ([plist objectForKey:@"NSCameraUsageDescription" ]) {
return YES;
}
return NO;
}



//--------------------------------------------------------------------------
Expand Down Expand Up @@ -173,6 +182,10 @@ - (void)scan:(CDVInvokedUrlCommand*)command {
NSString * error = NSLocalizedString(@"Access to the camera has been prohibited; please enable it in the Settings app to continue.",nil);
[self returnError:error callback:callback];
return;
} else if (![self isUsageDescriptionSet]) {
NSString * error = NSLocalizedString(@"NSCameraUsageDescription is not set in the info.plist", nil);
[self returnError:error callback:callback];
return;
}

processor = [[CDVbcsProcessor alloc]
Expand Down

0 comments on commit e516a87

Please sign in to comment.