For the complete documentation index, see llms.txt. This page is also available as Markdown.

Camera

Permission settings are required

openCameraBefore using it, you need to set camera permissions. Please check the permission setup guide first.

Take a photo

SDK function: openCamera

A function that launches the camera and returns the captured image.

Signature

function openCamera(options: { base64: boolean; maxWidth: number }): Promise<ImageResponse>;

Parameters

  • options · Required · OpenCameraOptions

    An options object used when launching the camera.

    • options.base64 · boolean

      A boolean value indicating whether to return the image in Base64 format. The default is false. trueto dataUri Instead, it returns a Base64-encoded string.

    • options.maxWidth · number

      A numeric value indicating the maximum width of the image. The default is 1024.

Properties

  • openPermissionDialog

    Displays a dialog to request camera access permission again. The user can choose one of "Allow", "Allow once", or "Don't allow". If they choose "Allow" or "Allow once", allowedit returns deniedis returned.

  • getPermission

    Returns the current status of camera access permission. allowedis the state where the user has granted camera access permission. deniedis the state where the user has denied camera access permission. notDeterminedis the state where camera access permission has never been requested.

If camera permission is denied in the Toss app settings, osPermissionDeniedis returned.

Return value

  • Promise<ImageResponse>

Returns an object containing information about the captured image. The structure of the returned object is as follows:

  • id: The unique identifier of the image.

  • dataUri: A data URI representing the image data.

Camera permission error

Error type: OpenCameraPermissionError

An error that occurs when camera permission is denied. When an error occurs, error instanceof OpenCameraPermissionErroryou can check it with.

Signature

Example

Get the photo taken after opening the camera

An example of taking a photo with the camera and getting the result. During this process, you can check the current camera permission status, and if there is no permission, you request it. If the user has denied permission or if the system has restricted permission, OpenCameraPermissionErroris returned.

Last updated

Was this helpful?