ios 判断打开相机权限_为什么我的iOS应用程序不询问用户访问相机的权限?

I develop iOS app and it uses camera. AVCaptureDeviceInput is used to interface to camera.

I checked Authorisation status as

- (void)checkDeviceAuthorizationStatus

{

NSString *mediaType = AVMediaTypeVideo;

[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {

if (granted)

{

//Granted access to mediaType

[self setDeviceAuthorized:YES];

}

else

{

//Not granted access to mediaType

dispatch_async(dispatch_get_main_queue(), ^{

[[[UIAlertView alloc] initWithTitle:@"AVCam!"

message:@"AVCam doesn't have permission to use Camera, please change privacy settings"

delegate:self

cancelButtonTitle:@"OK"

otherButtonTitles:nil] show];

[self setDeviceAuthorized:NO];

});

}

}];

}

When I launch the application, why it does not ask user permission for access to the camera?

So the app does not appear in settings/privacy/camera to manually allow to access camera.

Then show this error "AVCam doesn't have permission to use Camera, please change privacy settings" and app can't use the camera.

EDIT:

That means the app is not allowed to access the camera without asking user permission.

Not only camera, camera-roll also has the same problem.

All these things happened after I reset settings in Settings/Reset/Rest All Settings. Before that the app was working well.

解决方案

The problem is solved now. I need to trace back step by step and took me long time to solve the problem.

Some people suggested to include

NSCamerausageDescription Key. Actually it is necessary for devices with iOS 7 and above. I included the Key but still user permission is not asked yet.

Finally I found the problem at Info.plist.

There are some extra lines and I deleted three lines. Not sure how they are related to my problem.

Those I deleted are

(1)Get info string

(2)Bundle display name

(3)Application Category

After deleting these three lines in the info.plist. Then the app asks the user permission. The point is that you may need to check your Info.plist for such problem.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值