Skip to main content
Version: Current

Camera Actions

os.capturePhoto(options?: PhotoCameraOptions): Promise<Photo>

Opens the photo camera for the user to take a single photo. Returns a promise that resolves with the taken photo. Triggers the @onPhotoCameraOpened shout once opened.

While open, each time the user takes a photo the system will send a @onPhotoCaptured shout. Optionally accepts which camera to use for scanning. (front/back)

The first parameter is optional and is a PhotoCameraOptions and is the options that should be used for the photo camera.

Examples

Prompt the user to take a single photo.
const photo = await os.capturePhoto();
Take a single photo, defaulting to the front-facing camera.
await os.capturePhoto({
cameraType: "front"
});
Take a single photo, skipping the confirmation user step.
await os.capturePhoto({
skipConfirm: true
});
Take a single photo after a 3 second delay.
await os.capturePhoto({
takePhotoAfterSeconds: 3
});

os.closePhotoCamera(): Promise<void>

Closes the photo camera. Returns a promise that resolves once the camera has been closed. Triggers the @onPhotoCameraClosed shout once closed.

Examples

Close the photo camera
await os.closePhotoCamera();

os.openPhotoCamera(options?: PhotoCameraOptions): Promise<void>

Opens the photo camera. Returns a promise that resolves once the camera has been opened. Triggers the @onPhotoCameraOpened shout once opened.

While open, each time the user takes a photo the system will send a @onPhotoCaptured shout. Optionally accepts which camera to use for scanning. (front/back)

The first parameter is optional and is a PhotoCameraOptions and is the options that should be used for the photo camera.

Examples

Open the photo camera.
await os.openPhotoCamera();
Open the photo camera, defaulting to the front-facing camera.
await os.openPhotoCamera({
cameraType: "front"
});