Cordova camera plugin permission denial in android 6.0
<p>I am using ionic to develop a mobile application. The application requires camera. I added Cordova camera plugin to my project. Also I am using ngCordova wrapper. The application was working fine. Last day I used one device with android version 6.0 (Marshmallow) to test my app. when I click on the button it directly triggers the error. I done USB debugging, I got the error that </p>

<pre><code>Camera Error  "Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.CaptureActivity clip={text/uri-list U:file:///storage/emulated/0/Android/data/com.app.cameratest/cache/.Pic.jpg} (has extras) } from ProcessRecord{6fe7446 18933:com.app.cameratest/u0a471} (pid=18933, uid=10471) with revoked permission android.permission.CAMERA"
</code></pre>

<p>I googled it and found that in android 6.0, the permissions are disabled by default and when the time of attempting to access camera, it will ask for permission. I didn't get any permission seeking dialog box for camera. But I got the permission prompt for location plugin and file plugin. </p>

<p>My Cordova version is 6.0
camera plugin version 2.1.0
Cordova android API 23</p>

<p>I tried downgrading the Cordova Android version to 5.0 for changing target version to android 22.</p>

<p>Here is my code</p>

<pre class="lang-js prettyprint-override"><code>var options = {
            quality: 75,
            destinationType: Camera.DestinationType.FILE_URI,
            sourceType: 1,
            allowEdit: false,
            encodingType: 0,
            targetWidth: 380,
            targetHeight: 450,
            popoverOptions: CameraPopoverOptions,
            direction: 1,
            saveToPhotoAlbum: true
        };
 $cordovaCamera.getPicture(options).then(function(imageData) {
   console.log('image data': imageData);
},function(error) {
    console.error('Camera Error ', JSON.stringify(error));
 });
</code></pre>

<p>I tried updating the plugin to 2.1.1; still not working. If any one have any solution for that, please share. I don't know why this plugin doesn't ask for permission prompt. </p>

<p>The camera is working if we manually enable the permission of camera in settings menu. I don't want to interrupt the user flow in my application for that.</p>