Skip to content

Commit f427937

Browse files
committedMar 8, 2018
v5
1 parent 668881f commit f427937

File tree

3 files changed

+10
-43
lines changed

3 files changed

+10
-43
lines changed
 

‎config.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
<plugin name="cordova-custom-config" spec="^4.0.2" />
8585
<engine name="android" spec="^6.2.3" />
8686
<plugin name="cordova-plugin-whitelist" source="npm" />
87-
<plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
8887
<plugin name="cordova-plugin-camera" />
89-
88+
<plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
9089
</widget>

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@
5656
"android"
5757
]
5858
}
59-
}
59+
}

‎www/js/controllers.js

+8-40
Original file line numberDiff line numberDiff line change
@@ -24,51 +24,19 @@ $scope.scanBarcode = function($scope) {
2424

2525

2626

27+
var permissions = cordova.plugins.permissions;
28+
permissions.requestPermission(permissions.CAMERA, successCallback, errorCallback);
2729

28-
/*
29-
try{
30-
const permissions = cordova.plugins.permissions;
31-
permissions.checkPermission(permissions.CAMERA, function( status ){
32-
console.log(status)
33-
if ( status.hasPermission ) {
34-
}
35-
else
36-
{
37-
alert("L'application a besoin de pouvoir prendre une photo pour scanner les qrCode. Une fenêtre va s'ouvrir pour vous demander cette permission.");
38-
permissions.requestPermission(permissions.CAMERA, success, error);
39-
alert('On continue');
40-
}
41-
});
42-
43-
}catch(e){
44-
console.log('caught error in a chunk of code');
45-
alert("zut");
46-
alert(e);
47-
console.error(e);
48-
}
49-
50-
51-
function error() {
52-
alert("Vous n'avez pas autorisé l'application à prendre une photo.");
53-
}
54-
55-
function success( status ) {
56-
if( !status.hasPermission ) error();
30+
function successCallback()
31+
{
32+
alert('cool on a accès');
5733
}
58-
59-
60-
permissions.requestPermission(permissions.CAMERA, successz, errorz);
61-
62-
function errorz() {
63-
console.warn('Camera permission is not turned on');
34+
function errorCallback()
35+
{
36+
alert("zut on a pas accès")
6437
}
6538

66-
function successz( status ) {
67-
alert(status);
68-
if( !status.hasPermission ) error();
69-
}
7039

71-
*/
7240

7341
cordova.plugins.barcodeScanner.scan(
7442
function (result) {

0 commit comments

Comments
 (0)