Petnow LogoPetnow

React Native SDK Introduction

Introduces the structure and technical requirements of the Petnow React Native camera UI package.

Latest Version

PackageVersion
@petnow/react-native-camera-ui1.4.0

Server API recommended: Pet management such as registration, verification, and identification should be performed on the server via the Server API. The client only handles capture through the camera UI.


Package Features

@petnow/react-native-camera-ui is a UI layer wrapper around the iOS/Android native camera SDK (CameraController + CameraView). It provides the camera preview, detection overlays (nose/face markers, progress ring), and attention sounds as-is.

  • Hook-based API: usePetnowCamera({ apiKey }) returns a controller handle that owns the license and detection commands.
  • Bare component: <CameraView camera={...} /> renders the native preview + overlay.
  • Automatic single-hardware-session management: RN views are frequently destroyed and recreated by navigation, re-renders, and hot reloads, but the camera session is managed by the package as a singleton, so the view does not own it. After the last detach, the session is reused for a short grace period to reduce re-initialization cost. However, on Android only the most recently attached view has the preview, so there may be a brief gap where the previous/new view's preview is empty during a transition.

SDK Structure

Key Components

  • usePetnowCamera({ apiKey, isDebugMode })
    • Returns a controller handle that holds the license and exposes detection commands.
    • Exposes the SDK readiness state via camera.state.
  • <CameraView camera={camera} ... />
    • Binds to the controller and renders the native preview + detection overlay.
    • The camera is initialized on mount and cleaned up on unmount.

Technical Requirements

  • React Native: 0.75 or higher + New Architecture (Fabric/TurboModules) enabled
  • Android: minSdk 28 or higher. The host activity must be a PermissionAwareActivity (RN's default ReactActivity satisfies this — no separate FragmentActivity required)
  • iOS: 16.0 or higher
  • Petnow API key (if you don't have one, contact support@petnow.io)

Next Steps

On this page