SDK Initialization and Configuration

For the SDK to work, it requires a proper license key.

  • The license key can be requested at support@passiolife.com

SDK Initialization

When your component mounts, configure the SDK using your Passio provided developer key and start food detection.

const [isReady, setIsReady] = useState(false);

// Effect to configure the SDK and request camera permission
useEffect(() => {
  Promise.all([
    PassioSDK.configure({
      key: 'your-developer-key',
      autoUpdate: true,
    }),
    PassioSDK.requestCameraAuthorization(),
  ]).then(([sdkStatus, cameraAuthorized]) => {
    console.log(
      `SDK configured: ${sdkStatus.mode} Camera authorized: ${cameraAuthorized}`,
    );
    setIsReady(sdkStatus.mode === 'isReadyForDetection' && cameraAuthorized);
  });
}, []);

autoUpdate: true : Set to true to enable the download of AI models from Passio's servers.

The possible states of the SDK after calling configure. Switch on sdkStatus.mode to access the data associated with each state.

MODE: notReady, isReadyForDetection and error

notReady : SDK is not ready due to missing model files. Please download the specified file and call configure again, passing in the localFileURLs of the downloaded files.

isReadyForDetection: SDK configured successfully. This status much be reached before calling startFoodDetection

error: SDK failed to configure in an unrecoverable way. Please read the error message for more information

If at any point you need help from the Passio team, please reach out to us at support@passiolife.com

Last updated