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

Commit

Permalink
Redo usage descriptions (#626)
Browse files Browse the repository at this point in the history
* Remove usage description from plugin.xml

* Move usage description information to quirks section
  • Loading branch information
jcesarmobile authored Mar 15, 2018
1 parent 7cdfcb6 commit b9a32ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,13 @@ 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 Usage

Add the following to your config.xml:

```
<!-- add a version here, otherwise PGB will use whatever the latest version of the package on npm is -->
<plugin name="phonegap-plugin-barcodescanner">
<param name="CAMERA_USAGE_DESCRIPTION" value="To scan barcodes." />
</plugin>
<plugin name="phonegap-plugin-barcodescanner" />
```
On PhoneGap Build if you're using a version of cordova-android of 4 or less, ensure you're building with gradle:
```
Expand Down Expand Up @@ -144,6 +131,21 @@ A full example could be:
);
```

## iOS quirks ##

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. If you didn't provide the usage description, the app will crash before showing the dialog. Also, Apple will reject apps that access private data but don't provide an usage description.

To add this entry you can use the `edit-config` tag in the `config.xml` like this:

```
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
<string>To scan barcodes</string>
</edit-config>
```

## Windows quirks ##

* Windows implementation currently doesn't support encode functionality.
Expand Down
4 changes: 0 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
<param name="ios-package" value="CDVBarcodeScanner"/>
</feature>
</config-file>
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
<string>$CAMERA_USAGE_DESCRIPTION</string>
</config-file>
<preference name="CAMERA_USAGE_DESCRIPTION" default=" "/>
<resource-file src="src/ios/scannerOverlay.xib"/>
<resource-file src="src/ios/CDVBarcodeScanner.bundle"/>
<header-file src="src/ios/zxing-all-in-one.h"/>
Expand Down

0 comments on commit b9a32ba

Please sign in to comment.