Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Issue #270: OS 10 requires Camera permission reason
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst committed Sep 7, 2016
1 parent 7dd0e84 commit 380a56a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 16 additions & 5 deletions README.md
Expand Up @@ -9,7 +9,7 @@ Follows the [Cordova Plugin spec](https://cordova.apache.org/docs/en/latest/plug

## Installation


This requires phonegap 5.0+ ( current stable v3.0.0 )

phonegap plugin add phonegap-plugin-barcodescanner
Expand Down Expand Up @@ -42,11 +42,22 @@ Note: Windows 10 applications can not be build for `AnyCPU` architecture, which
cordova run windows -- --archs=x86
```

Note: Since iOS 10 it's mandatory to add a `NSCameraUsageDescription` in the info.plist.

`NSCameraUsageDescription` describes the reason that the app accesses the user’s camera.
When the system prompts the user to allow access, this string is displayed as part of the dialog box.

To add this entry you can pass the following variable on plugin install.

```
cordova plugin add phonegap-plugin-barcodescanner --variable CAMERA_USAGE_DESCRIPTION="To scan barcodes"
```

### PhoneGap Build
If you're using [PhoneGap Build](https://build.phonegap.com/) please make sure you specify `gradle` as your Android build tool in `config.xml`: `<preference name="android-build-tool" value="gradle" />`.

## Using the plugin ##
The plugin creates the object `cordova/plugin/BarcodeScanner` with the method `scan(success, fail)`.
The plugin creates the object `cordova/plugin/BarcodeScanner` with the method `scan(success, fail)`.

The following barcode types are currently supported:
### Android
Expand Down Expand Up @@ -138,7 +149,7 @@ A full example could be:
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
},
function (error) {
alert("Scanning failed: " + error);
},
Expand All @@ -154,7 +165,7 @@ A full example could be:

## Encoding a Barcode ##

The plugin creates the object `cordova.plugins.barcodeScanner` with the method `encode(type, data, success, fail)`.
The plugin creates the object `cordova.plugins.barcodeScanner` with the method `encode(type, data, success, fail)`.

Supported encoding types:

Expand Down Expand Up @@ -186,7 +197,7 @@ Cancelling a scan on BlackBerry 10 is done by touching the screen.

## Thanks on Github ##

So many -- check out the original [iOS](https://github.com/phonegap/phonegap-plugins/tree/DEPRECATED/iOS/BarcodeScanner), [Android](https://github.com/phonegap/phonegap-plugins/tree/DEPRECATED/Android/BarcodeScanner) and
So many -- check out the original [iOS](https://github.com/phonegap/phonegap-plugins/tree/DEPRECATED/iOS/BarcodeScanner), [Android](https://github.com/phonegap/phonegap-plugins/tree/DEPRECATED/Android/BarcodeScanner) and
[BlackBerry 10](https://github.com/blackberry/WebWorks-Community-APIs/tree/master/BB10-Cordova/BarcodeScanner) repos.

## Licence ##
Expand Down
4 changes: 3 additions & 1 deletion plugin.xml
Expand Up @@ -11,6 +11,8 @@
<repo>https://github.com/phonegap/phonegap-plugin-barcodescanner</repo>
<issue>https://github.com/phonegap/phonegap-plugin-barcodescanner/issues</issue>

<preference name="CAMERA_USAGE_DESCRIPTION" default=" " />

<engines>
<engine name="cordova" version=">=3.0.0" />
</engines>
Expand All @@ -30,7 +32,7 @@

<!-- Usage description of the Camera, mandatory since iOS 10 -->
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
<string/>
<string>$CAMERA_USAGE_DESCRIPTION</string>
</config-file>

<resource-file src="src/ios/scannerOverlay.xib" />
Expand Down

0 comments on commit 380a56a

Please sign in to comment.