QRCodeReaderViewController
QRCodeReaderViewController copied to clipboard
NSInvalidArgumentException: Unsupported type type found. Use -availableMetadataObjectTypes.
Hey there... I am using QRCodeReaderViewController in iOS 8 app and I took your sample code as-is to show the QR code reader.
But I am getting an exception:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureMetadataOutput setMetadataObjectTypes:] - unsupported type found. Use -availableMetadataObjectTypes.'
I've seen on this article a potential explanation but it seems that you already setup the AVCaptureMetadataOutput and AVCaptureSession correctly.
Hi,
On which device have you test it?
Note: you can check that the device supports the reader by calling the [QRCodeReader isAvailable]
method.
My device is an iPhone 5s with iOS 8.1.3. The thing is that it was working 2 weeks ago on this very device. Then, I updated my pods and got the last version of your library, and now I get this crash...
Is the example project works fine or it crashes too?
If you add the exception breakpoint to your project where the app crashes and with which metadataObjectTypes?
The error may also comes from the camera permission (I add method to check that in the next release).
Ok the example project runs fine.... And you were right, it was a permission problem. The camera permission was denied, even if after removing and reinstalling the app (the privacy settings probably remembers bundle IDs for a while).
So, the crash is gone. Thanks for the help!
I also updated the pod to your last commit (777f5ee) and implemented the QRCodeReader -supportsMetadataObjectTypes: method to check if the device is allowed or able to use the camera. But, if the user switches to the Settings > Privacy > Camera to enable camera access for the app, and switches back to the app, the QRCodeReader method doesn't reflect the change.
Just got bit with this bug. You can check camera permission first before presenting the view controller
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(authStatus == AVAuthorizationStatusAuthorized || authStatus == AVAuthorizationStatusNotDetermined) {
// present QRCodeReaderViewController
}
else if(authStatus == AVAuthorizationStatusDenied) {
// denied: show alert or something
}
else {
// impossible?!!
}
Hi
I am using QRCodeReaderViewController in iOS 9.2.1 at iPad mini
Example project runs fine
But in my project I am getting an exception:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureMetadataOutput setMetadataObjectTypes:] - unsupported type found. Use -availableMetadataObjectTypes.
App crashed before request camera permission AVAuthorizationStatus notDetermed Everything works at other devices normally For example: iPhone 6 with iOS 9.2.1
We are seeing this as well, good to see that there are some workarounds.
Hello guys, just catched this issue right now.
The feature is that lazy init
works on some tricky way - you can't call this object till it's inited and even check it's state. It's getting inited only after getting access to camera. Until this moment you have no control on this variable.
Solved it with simple workaround - added another variable like cameraWorks = false
beside my lazy controller variable, set it to true when I get access to camera, and every time I want to stop\start\call it - I check my boolean variable.