1
在iOS上,我的应用程序会检查使用摄像头的权限,然后如果一切顺利,请继续执行相机操作。Cordova/Ionic 2摄像头权限问题iOS 10.2.1
的问题是,:
- 的iOS 8:这一切工作正常,
- 的iOS 9.2.1:我得到的错误警报。
然而,应用程序仍然允许我以后使用相机。
我在做什么错在iOS?
这里的简化我的方法为简洁:
checkPermissionsForCamera() {
this._Diagnostic.isCameraAuthorized().then(cameraIsAuthorised => {
if (cameraIsAuthorised) {
getPhoto(); // etc....
}
else {
this._Diagnostic.requestCameraAuthorization().then(cameraAuthorisationGranted => {
if (cameraAuthorisationGranted.toLowerCase() == 'granted') {
getPhoto(); // etc....
}
else {
alert('Please go to your device settings and enable camera permissions.');
}
});
}
});
}
仅供参考 - 我有我的plist文件这些键:
<key>NSCameraUsageDescription</key>
<string>This app requires camera access to function properly.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires photo library access to function properly</string>
你使用什么插件?你能否提供获得许可的本地代码? – Sergey
我正在使用Ionic Native Diagnostics包装器,它使用Cordova诊断插件:https://ionicframework.com/docs/native/diagnostic/ – Dave
如果您有实际的答案,这些评论都不会有帮助。添加示例代码作为答案。 – Dave