Home > OS >  iOS app does not ask camera and microphone permissions on TestFlight?
iOS app does not ask camera and microphone permissions on TestFlight?

Time:03-02

I've an issue that is unusual. When I test my app with XCode evertything is working on my iphone and the other iphones, the app asks to user for all permissions. But when I added my app to TestFlight, the app does not ask camera and microphone permissions to user? "Privacy - Camera Usage Description" and "Privacy - Photo Library Usage Description" keys are already added to info.plist file. The app behaves different on TestFlight, how can it be?

CodePudding user response:

To make sure your app has permission before capturing media, follow the steps below.

Configure Your App's Info.plist File

iOS requires that your app provide static messages to display to the user when the system asks for camera or microphone permission:

  • If your app uses device cameras, include the Privacy - Camera Usage Description key in your app’s Info.plist file.
  • If your app uses device photo library, include the Privacy - Photo Library Usage Description key in your app’s Info.plist file

Verify and Request Authorization for Capture

You can add below code in AppDelegate main file OR while click on capture media to request access authorization.

import AVFoundation

AVCaptureDevice.requestAccess(for: .video) { granted in

            if granted {
            // Setup your code.
            }
        }

Apple Ref Link https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_ios

CodePudding user response:

If the user has previously denied the use of the camera, then the status will be AVAuthorizationStatusDenied and the dialog will not be displayed when asking for permissions.

  • Related