简体   繁体   中英

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

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?

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.

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

Actually, we faced with the similar issue recently. In our case, the solution was related to signing.

If you're checked the automatically manage signing box in Xcode, you can try this to fix this issue:

  1. Create 'Distribution' certificate on Apple Developer Console.
  2. Create 'App Store' provisioning profile by selecting the created certificate in Step 1.
  3. Download certificate and add to your keychain.
  4. In Xcode update the release signing part with this newly created provisioning profile and certificate.

By these steps we fixed our permission issue in TestFlight. I hope this post will help someone in someday.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM