startCamera() fails in IOS
See original GitHub issueHi, I’ve built a simple Ionic 2 app that startCamera() when pushing a button. The code is:
openCamera() {
let options = {
x: 0,
y: 0,
width: 120,
height: 120,
camera: "back",
toBack: false,
tapPhoto: false,
previewDrag: false
};
console.log("camera: " + options.camera);
this.cameraPreview.startCamera(options).then(() => {
console.log("startCamera");
Issue When starting the camera the app exits without any message or return code. Note the same app works perfectly when tested an an Android device.
Plugin version: I used the plugin 0.9.0 from the master.
Ionic Info:
Cordova CLI: 6.5.0
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
ios-deploy version: 1.9.1
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v7.8.0
Xcode version: Xcode 8.3.1 Build version 8E1000a
IOS Device:
iPhone SE
IOS 10.3.1
Edit:
I finally found what’s happens: IOS 10 requires an key/value pair for the description of the usage of the camera when it asks authorisation to use the camera to the user. If this information is not provided, the app crashes. I tried to pass the following variable in the installation command of the plugin but, did not work:
--variable CAMERA_USAGE_DESCRIPTION="My description"
I finally set it directly in the plist of the Xcode project using Xcode.
Does somebody knows how to do it properly using Ionic 2 framework ?
Thanks a lot !
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (4 by maintainers)
Thanks for the pointer @SVANNER - I was able to update this from Xcode.
+
in the Custom iOS Target PropertiesPrivacy - Camera Usage Description
” as the keytaking pictures
” as the TypeHi @SVANNER, I had the same problem, I solved it by adding the following configuration in the plugin.xml file
<platform name="ios"> .... <config-file target="*-Info.plist" parent="NSCameraUsageDescription"> <string>Your description</string> </config-file>