nativescript-barcodescanner
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -5,8 +5,2 @@ var barcodescanner = {}; | ||
barcodescanner.available = function () { | ||
return new Promise(function (resolve) { | ||
resolve(true); | ||
}); | ||
}; | ||
barcodescanner.hasCameraPermission = function () { | ||
@@ -13,0 +7,0 @@ return new Promise(function (resolve) { |
var barcodescanner = require("./barcodescanner-common"); | ||
var appModule = require("application"); | ||
var camModule = require("camera"); | ||
@@ -10,3 +11,2 @@ var SCANNER_REQUEST_CODE = 444; | ||
barcodescanner._cameraPermissionGranted = function () { | ||
@@ -21,2 +21,14 @@ var hasPermission = android.os.Build.VERSION.SDK_INT < 23; // Android M. (6.0) | ||
barcodescanner.available = function () { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
resolve(camModule.isAvailable()); | ||
} catch (ex) { | ||
console.log("Error in barcodescanner.available: " + ex); | ||
// let's just assume it's ok | ||
resolve(true); | ||
} | ||
}); | ||
}; | ||
barcodescanner.hasCameraPermission = function () { | ||
@@ -140,3 +152,3 @@ return new Promise(function (resolve) { | ||
}; | ||
// we need to cache and restore the context, otherwise the dialogs module will be broken (and possibly other things as well) | ||
@@ -143,0 +155,0 @@ barcodescanner.rememberedContext = appModule.android.currentContext; |
{ | ||
"name": "nativescript-barcodescanner", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Scan QR/barcodes with a {N} app.", | ||
@@ -5,0 +5,0 @@ "main": "barcodescanner.js", |
@@ -109,3 +109,5 @@ # NativeScript BarcodeScanner | ||
### function: available | ||
Note that the Android implementation will always return `true` at the moment. | ||
Note that the iOS implementation will always return `true` at the moment, | ||
on Android we actually check for a camera to be available. | ||
```js | ||
@@ -112,0 +114,0 @@ var barcodescanner = require("nativescript-barcodescanner"); |
1443328
423
151