question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

startCamera() fails in IOS

See original GitHub issue

Hi, 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:closed
  • Created 6 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
F1LT3Rcommented, Dec 14, 2017

Thanks for the pointer @SVANNER - I was able to update this from Xcode.

  • Goto: Xcode > Targets > Info
  • Click the little + in the Custom iOS Target Properties
  • Enter: “Privacy - Camera Usage Description” as the key
  • Enter: “taking pictures” as the Type
screen shot 2017-12-14 at 3 50 58 pm
1reaction
tarikboschicommented, May 2, 2017

Hi @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>

Read more comments on GitHub >

github_iconTop Results From Across the Web

startCamera() crashes the App for iOS · Issue #405 - GitHub
Hello, I'm using this plugin for my ios app, when this line is executed: this.cameraPreview. ... startCamera() crashes the App for iOS #405....
Read more >
Camera not working on iOS16 | Apple Developer Forums
I installed the iOS16 beta to test the new features and everything works well except the camera, which when I access it the...
Read more >
Screen capture during video preview fails - Stack Overflow
The image returned is just all white. How do I grab a screenshot of what's on the screen while doing a video preview?...
Read more >
10 Ways to Fix It When an iPhone Camera is Not Working
If your iPhone's camera isn't working, first try these software and hardware fixes in order before contacting Apple.
Read more >
[Solved]-Error initializing capture component: 0, 480, 360
You cannot take image via Mac's webcam from iPhone Simulator. For camera, you need to test it on a device. if( m_metaioSDK )...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found