mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-18 19:22:51 +08:00
parent
a6706aef5f
commit
9f480b10cb
32
README.md
32
README.md
@ -76,23 +76,33 @@ Documentation consists of template and API docs produced from the plugin JS code
|
||||
|
||||
### iOS Quirks
|
||||
|
||||
Since iOS 10 it's mandatory to add a `NSCameraUsageDescription` and `NSPhotoLibraryUsageDescription` in the info.plist.
|
||||
Since iOS 10 it's mandatory to provide an usage description in the `info.plist` if trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will displayed as part of the permission dialog box, but 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.
|
||||
|
||||
- `NSCameraUsageDescription` describes the reason that the app accesses the user’s camera.
|
||||
This plugins requires the following usage descriptions:
|
||||
|
||||
- `NSCameraUsageDescription` describes the reason that the app accesses the user's camera.
|
||||
- `NSPhotoLibraryUsageDescription` describes the reason the app accesses the user's photo library.
|
||||
- `NSLocationWhenInUseUsageDescription` describes the reason the app accesses the user's location. (Set it if you have `CameraUsesGeolocation` preference set to `true`)
|
||||
|
||||
When the system prompts the user to allow access, this string is displayed as part of the dialog box.
|
||||
To add these entries into the `info.plist`, you can use the `edit-config` tag in the `config.xml` like this:
|
||||
|
||||
To add this entry you can pass the following variables on plugin install.
|
||||
```
|
||||
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
|
||||
<string>need camera access to take pictures</string>
|
||||
</edit-config>
|
||||
```
|
||||
|
||||
- `CAMERA_USAGE_DESCRIPTION` for `NSCameraUsageDescription`
|
||||
- `PHOTOLIBRARY_USAGE_DESCRIPTION` for `NSPhotoLibraryUsageDescription`
|
||||
```
|
||||
<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
|
||||
<string>need to photo library access to get pictures from there</string>
|
||||
</edit-config>
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="your usage message" --variable PHOTOLIBRARY_USAGE_DESCRIPTION="your usage message"
|
||||
|
||||
If you don't pass the variable, the plugin will add an empty string as value.
|
||||
```
|
||||
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
|
||||
<string>need location access to find things nearby</string>
|
||||
</edit-config>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
@ -18,23 +18,33 @@ the system's image library.
|
||||
|
||||
### iOS Quirks
|
||||
|
||||
Since iOS 10 it's mandatory to add a `NSCameraUsageDescription` and `NSPhotoLibraryUsageDescription` in the info.plist.
|
||||
Since iOS 10 it's mandatory to provide an usage description in the `info.plist` if trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will displayed as part of the permission dialog box, but 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.
|
||||
|
||||
- `NSCameraUsageDescription` describes the reason that the app accesses the user’s camera.
|
||||
This plugins requires the following usage descriptions:
|
||||
|
||||
- `NSCameraUsageDescription` describes the reason that the app accesses the user's camera.
|
||||
- `NSPhotoLibraryUsageDescription` describes the reason the app accesses the user's photo library.
|
||||
- `NSLocationWhenInUseUsageDescription` describes the reason the app accesses the user's location. (Set it if you have `CameraUsesGeolocation` preference set to `true`)
|
||||
|
||||
When the system prompts the user to allow access, this string is displayed as part of the dialog box.
|
||||
To add these entries into the `info.plist`, you can use the `edit-config` tag in the `config.xml` like this:
|
||||
|
||||
To add this entry you can pass the following variables on plugin install.
|
||||
```
|
||||
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
|
||||
<string>need camera access to take pictures</string>
|
||||
</edit-config>
|
||||
```
|
||||
|
||||
- `CAMERA_USAGE_DESCRIPTION` for `NSCameraUsageDescription`
|
||||
- `PHOTOLIBRARY_USAGE_DESCRIPTION` for `NSPhotoLibraryUsageDescription`
|
||||
```
|
||||
<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
|
||||
<string>need to photo library access to get pictures from there</string>
|
||||
</edit-config>
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="your usage message" --variable PHOTOLIBRARY_USAGE_DESCRIPTION="your usage message"
|
||||
|
||||
If you don't pass the variable, the plugin will add an empty string as value.
|
||||
```
|
||||
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
|
||||
<string>need location access to find things nearby</string>
|
||||
</edit-config>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
14
plugin.xml
14
plugin.xml
@ -167,20 +167,6 @@
|
||||
<framework src="CoreGraphics.framework" />
|
||||
<framework src="AVFoundation.framework" />
|
||||
|
||||
<preference name="CAMERA_USAGE_DESCRIPTION" default=" " />
|
||||
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
|
||||
<string>$CAMERA_USAGE_DESCRIPTION</string>
|
||||
</config-file>
|
||||
|
||||
<preference name="PHOTOLIBRARY_USAGE_DESCRIPTION" default=" " />
|
||||
<config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
|
||||
<string>$PHOTOLIBRARY_USAGE_DESCRIPTION</string>
|
||||
</config-file>
|
||||
|
||||
<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
|
||||
<string></string>
|
||||
</config-file>
|
||||
|
||||
</platform>
|
||||
|
||||
<!-- blackberry10 -->
|
||||
|
Loading…
Reference in New Issue
Block a user