Requested
Considered
6 instances
[AVCaptureSession startRunning] must be known as from background thread.Calling it on essential thread can result in ui unresponsiveness] Tips on how to repair this in goal.
I’ve one undertaking the place i scan the barcode and present the main points . i’ve imported library which makes use of AVfoundation internally.
- (void)checkCameraPermission {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (authStatus == AVAuthorizationStatusAuthorized) {
if (!qrCodeView.isRunning) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[qrCodeView startReading];
});
}
}
}
when ever [qrCodeView startReading]; will get known as i get the error as [AVCaptureSession startRunning] must be known as from background thread. Calling it on essential thread can result in ui unresponsiveness]
//I’ve tried options given under however no luck
-
(void)checkCameraPermission {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (authStatus == AVAuthorizationStatusAuthorized) {
if (!qrCodeView.isRunning) {
dispatch_async(dispatch_get_main_queue(), ^{
[qrCodeView startReading];
});
}
}
else if (authStatus == AVAuthorizationStatusNotDetermined) {
NSLog(@”%@”, @”Digital camera entry not decided. Ask for permission.”);[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { if (granted) { NSLog(@"Granted access to %@", AVMediaTypeVideo); if (!qrCodeView.isRunning) { dispatch_async(dispatch_get_main_queue(), ^{ [qrCodeView startReading]; }); } } else { NSLog(@"Not granted entry to %@", AVMediaTypeVideo); [self camDenied]; } }];
}
else if (authStatus == AVAuthorizationStatusRestricted) {
// My very own Helper class is used right here to pop a dialog in a single easy line.
[self showAlertTitle:@”Error” withMessage:@”You’ve been restricted from using the camera on this device. Without camera access, this feature won’t work. Please contact the device owner so they can give you access.” onView:self andCompletionHandler:nil];
}
else {
[self camDenied];
}
}
//I need the answer tips on how to keep away from this and scan barcode efficiently *
lang-objectivec