Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to check if app has Camera permission on iOS

TomaszBTomaszB PLUniversity
edited October 2015 in Xamarin.Forms

I need to check if appliaction has camera permission before launching ZXing barcode scanner or Augumented Reality page.

If I just launch them and user has disabled camera access in ios settings - barcode scanner either crashes or never returns and AR just crashes.

I tried :
but it returns true = camera supported.

Exception generated by launching AR (Wikitude)
ex {Foundation.MonoTouchException: Objective-C exception thrown. Name: NSGenericException Reason: *** AVCaptureSession can't startRunning between calls to beginConfiguration / commitConfiguration Native stack trace: 0 CoreFoundation 0x000000018514e0a0 + 160 1 libobjc.A.dylib 0x0000000195afc0e4 objc_exception_throw + 60 2

If app has camera permission AR starts OK.


Best Answer


  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    Why don't you set the camera-permission to your app?

  • TomaszBTomaszB PLUniversity

    Thanks Adam, this is what was needed. I re-worded it to Xamarin API syntax.

            public static bool IsCameraAuthorized(){            
                    AVAuthorizationStatus authStatus = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video);
                    if(authStatus == AVAuthorizationStatus.Authorized) {
                        // do your logic
                        return true;
                    } else if(authStatus == AVAuthorizationStatus.Denied){
                        // denied
                        return false;
                    } else if(authStatus == AVAuthorizationStatus.Restricted){
                        // restricted, normally won't happen
                        return false;
                    } else if(authStatus == AVAuthorizationStatus.NotDetermined){
                        // not determined?!
                        return false;
                    } else {
                        return false;
                        // impossible, unknown authorization status
Sign In or Register to comment.