Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSInvalidArgumentException: Unsupported type type found. Use -availableMetadataObjectTypes. #4

Open
nashfive opened this issue Mar 4, 2015 · 8 comments

Comments

@nashfive
Copy link

nashfive commented Mar 4, 2015

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.

@yannickl
Copy link
Owner

yannickl commented Mar 5, 2015

Hi,

On which device have you test it?

Note: you can check that the device supports the reader by calling the [QRCodeReader isAvailable] method.

@nashfive
Copy link
Author

nashfive commented Mar 5, 2015

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...

@yannickl
Copy link
Owner

yannickl commented Mar 5, 2015

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).

@nashfive
Copy link
Author

nashfive commented Mar 5, 2015

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.

@soemarko
Copy link

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?!!
        }

@IvanSavin
Copy link

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

@chrisballinger
Copy link

We are seeing this as well, good to see that there are some workarounds.

@kioltk
Copy link

kioltk commented Feb 13, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants