Skip to content

ReactNative SDK Reference / VitalSignCamera

Class: VitalSignCamera

The <VitalSignCamera> is the main component performing Vital Sign Scanning. On the scanning screen of the app, declare this component with the following required properties:

  • isActive: A boolean value that specifies whether the VitalSignCamera is turned on and processing the video frames.
  • userInfo: The information of the user taking the scan, such as age and gender. Another importatant information is the
  • userId. The userId is obtained from us and has to be specified here.
  • config: The information of the server, containing the apiKey for accessing the server. The apiKey is obtained from is and has to be specified here.
  • sdkCredentials: A convenient object combining both the userId and apiKey into a single prop. When you provide this, the native SDK will merge the values into the plugin's config and userInfo as necessary.
  • onVideoFrameProcessed: The callback function that observes all the important information from the component, such as scanning condtions, error, and the vital sign sanning result.

Example

tsx
function App() {
  const devices = useCameraDevices('wide-angle-camera')
  const device = devices.back

  if (device == null) return <LoadingView />
  return (
    <VitalSignCamera
      style={StyleSheet.absoluteFill}
      userInfo={{age:30, gender:Gener.Male, userId:"__YOUR_USER_ID__"}}
     sdkCredentials={{apiKey: "__YOUR_API_KEY__", userId: "__YOUR_USER_ID__"}}
      config={{apiKey:"__YOUR_API_KEY__"}}
      onVideoFrameProcessed:{onVideoFrameProcessed}
      isActive={true}
    />
  )
}

Component

Constructors

new VitalSignCamera(props)

new VitalSignCamera(props): VitalSignCamera

Parameters

props: CameraProps

Returns

VitalSignCamera

Methods

startScanning()

startScanning(): Promise<void>

Start the scanning

Returns

Promise<void>

Example

ts
await camera.current.startScanning()

stopScanning()

stopScanning(): Promise<void>

Stop the scanning

Returns

Promise<void>

Example

ts
await camera.current.stopScanning()

getAvailableCameraDevices()

static getAvailableCameraDevices(): Promise<CameraDevice[]>

Get a list of all available camera devices on the current phone.

Returns

Promise<CameraDevice[]>

Throws

CameraRuntimeError When any kind of error occured while getting all available camera devices. Use the code property to get the actual error

Example

ts
const devices = await VitalSignCamera.getAvailableCameraDevices()
const filtered = devices.filter((d) => matchesMyExpectations(d))
const sorted = devices.sort(sortDevicesByAmountOfCameras)
return {
  back: sorted.find((d) => d.position === "back"),
  front: sorted.find((d) => d.position === "front")
}

getCameraPermissionStatus()

static getCameraPermissionStatus(): Promise<CameraPermissionStatus>

Gets the current Camera Permission Status. Check this before mounting the Camera to ensure the user has permitted the app to use the camera.

To actually prompt the user for camera permission, use requestCameraPermission().

Returns

Promise<CameraPermissionStatus>

Throws

CameraRuntimeError When any kind of error occured while getting the current permission status. Use the code property to get the actual error


getMicrophonePermissionStatus()

static getMicrophonePermissionStatus(): Promise<CameraPermissionStatus>

Gets the current Microphone-Recording Permission Status. Check this before mounting the Camera to ensure the user has permitted the app to use the microphone.

To actually prompt the user for microphone permission, use requestMicrophonePermission().

Returns

Promise<CameraPermissionStatus>

Throws

CameraRuntimeError When any kind of error occured while getting the current permission status. Use the code property to get the actual error


requestCameraPermission()

static requestCameraPermission(): Promise<CameraPermissionRequestResult>

Shows a "request permission" alert to the user, and resolves with the new camera permission status.

If the user has previously blocked the app from using the camera, the alert will not be shown and "denied" will be returned.

Returns

Promise<CameraPermissionRequestResult>

Throws

CameraRuntimeError When any kind of error occured while requesting permission. Use the code property to get the actual error


requestMicrophonePermission()

static requestMicrophonePermission(): Promise<CameraPermissionRequestResult>

Shows a "request permission" alert to the user, and resolves with the new microphone permission status.

If the user has previously blocked the app from using the microphone, the alert will not be shown and "denied" will be returned.

Returns

Promise<CameraPermissionRequestResult>

Throws

CameraRuntimeError When any kind of error occured while requesting permission. Use the code property to get the actual error