【问题标题】:Flutter iOS - Not asking for Camera permissionFlutter iOS - Not asking for Camera permission
【发布时间】:2022-12-01 19:10:55
【问题描述】:

Implemented the example from the camera package here:

https://pub.dev/packages/camera/example

While testing on the physical device (running iOS 16), the app builds and runs fine, however the phone does not ask for any permissions to access the camera or microphone.

The following code has been added to ios/Runner/Info.plist

<key>NSCameraUsageDescription</key>
<string>Testing the Camera integration.</string>
<key>NSMicrophoneUsageDescription</key>
<string>To add sounds to the videos you record.</string>

The iOS Deployment Target has been set toiOS 11.0

Note: I can assure you that the app has not been granted these permissions already because:

  1. It is not showing up in the app settings
  2. The app is not listed in Settings>Privacy & Security>Camera

    Am I missing something?

【问题讨论】:

  • Check your app permissions from settings. Maybe you allowed it sometime ago.
  • @Md.KamrulAmin I have checked and there is no camera option in the settings, and if I go to privacy and camera, then the app is not listed there either.
  • By any chance are you using IOS simulator?
  • @Md.KamrulAmin nope, testing on a physical device running iOS 16
  • this feels like a pretty weird problem. Please check your app in a device running a lower OS than 16. If you see it working as desired in lower OS then you can be sure that this package does not support IOS 16 yet.

标签: flutter flutter-ios


【解决方案1】:

If the system not asking the permission than it was granted before

【讨论】:

  • Then it would show up in the app settings OR the Settings>Privacy & Security>Camera However it is not showing there.
【解决方案2】:

https://pub.dev/packages/permission_handler

To avoid problems, have it checked before accessing the camera to see if it has permission.

Map<Permission, PermissionStatus> statuses = await [
  Permission.camera,
  Permission.microphone,
].request();

【讨论】:

  • I haven't implemented the permission_handler, simply because the camera package and the flutter docs, don't explicitly ask for the permission_handler package.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-19
  • 1970-01-01
  • 2022-12-07
  • 1970-01-01
  • 2022-11-20
  • 2018-08-26
相关资源
最近更新 更多