@nacrejs/camera
v0.0.1
Published
Nacre 的拍照能力:用系统的拍照界面拍一张照片。装了才有 UIImagePickerController
Readme
@nacrejs/camera
A capability package for Nacre, a JavaScript runtime for iOS apps: taking a photo with the system camera interface. It provides UIImagePickerController. The app has it only if the project installs this package.
Install
In a Nacre project, three steps.
1. Install the package.
npm install @nacrejs/camera2. Bring in its types at the top of the entry file.
/// <reference types="@nacrejs/types" />
/// <reference types="@nacrejs/camera" />3. Write its usage description in nacre.config.json.
{
"ios": {
"infoPlist": {
"NSCameraUsageDescription": "Used to take a profile photo"
}
}
}NSCameraUsageDescription is the sentence iOS shows the user when the app asks for camera access. Only you can write it, so the package doesn't ship one. If it's missing, nacre generate stops with an error that names the key. See Writing usage descriptions.
Effect: after you regenerate ios/ and rebuild, the app includes this capability, and typeof UIImagePickerController !== 'undefined' is true.
Without the package, its classes don't exist: reading one throws ReferenceError, and type checking reports it first.
For how to use it, see Taking photos. For all capability packages, see Core and capability packages.
License
FSL-1.1-MIT, see LICENSE.md.
