ANDROID - Barcode scanner app doesn't ask for camera permissions


#1

Hello!

I have an app that reads QR codes. It’s built on iOS and Android. On iOS works fine. My problems are in Android. When I tap the “scan” button nothing happens.

If I add camera permissions from: Settings > My App > Camera, the app works but on every clean installation the app doesn’t ask for camera permissions and barcode fails again.

This is my ionic info:

Cordova CLI: 6.1.1
Gulp version: CLI version 3.8.11
Gulp local: Local version 3.9.1
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: Not installed
ios-sim version: 3.1.1
OS: Mac OS X El Capitan
Node Version: v5.5.0
Xcode version: Xcode 7.3 Build version 7D175

If I look into the AndroidManifest file, I can read this:

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="false" />

I don’t know how can I do to fix that problem…

This is the plugin that I’m using: https://github.com/phonegap/phonegap-plugin-barcodescanner

thanks!


#2

Until version 5 of android, permissions are accepted when installing the app. In the new version is at run time, so I guess it will have to add java function to request the permission. Unfortunately, I don’t know how that part works.
check out this link, might help you something:
http://developer.android.com/intl/es/training/permissions/requesting.html

Moreover, I found a library on gitHub, but I don’t test it. Here’s the link;

I need fix this issue like you, but now is not a priority.
If you find the solution with this library, reply me.


#3

What about this : https://www.npmjs.com/package/cordova-plugin-android-permissions
I did not try yet, but seems useful to handle new Android 23 permissions policy.