@sagepilot-ai/react-native-camera-addon
v0.3.6
Published
Optional CameraX attachment picker addon for the Sagepilot React Native SDK
Maintainers
Readme
@sagepilot-ai/react-native-camera-addon
Optional Android CameraX attachment picker for @sagepilot-ai/react-native-sdk.
Install this package only when you want Sagepilot to provide an in-app Android CameraX picker. Apps that do not install it can keep the smaller base SDK install.
This is not a replacement SDK. Your app always installs and configures @sagepilot-ai/react-native-sdk first, then adds this package only when it wants the optional CameraX picker.
Peer Dependency
This addon declares @sagepilot-ai/react-native-sdk as a peer dependency. It imports the base SDK's file-picker types, shared file limits, and Android camera-permission helper, but the host app must still install the base SDK directly so there is only one configured SagepilotChat instance.
For this release line, use:
npm install @sagepilot-ai/react-native-sdk@latest react-native-webview
npm install @sagepilot-ai/react-native-camera-addon@latestInstall Flow
Install the base SDK and WebView:
npm install @sagepilot-ai/react-native-sdk@latest react-native-webviewThen install the CameraX addon:
npm install @sagepilot-ai/react-native-camera-addon@latestIf your app already has the base SDK installed, run only the addon install command.
After adding this package, run a clean native Android rebuild. A Metro reload is not enough because React Native autolinking registers the new native module only during the native build:
cd android && ./gradlew clean
cd .. && npx react-native run-androidExpo apps should run a fresh native build, for example:
npx expo run:androidOn device, verify the chat attachment menu shows the native addon sources: Take photo, Choose from gallery, and Browse files.
If the app was only Metro-reloaded after installing the addon, NativeModules.SagepilotInAppCamera is not registered yet. In that state createSagepilotCameraXFilePicker() returns undefined, the base SDK receives no filePicker, and the widget falls back to the WebView file input.
Configure
import { SagepilotChat } from "@sagepilot-ai/react-native-sdk";
import { createSagepilotCameraXFilePicker } from "@sagepilot-ai/react-native-camera-addon";
await SagepilotChat.configure({
key: "workspace_id:channel_id",
filePicker: createSagepilotCameraXFilePicker()
});Mount SagepilotChatProvider from the base SDK once near the top of your app. The addon only supplies the filePicker adapter used by SagepilotChat.configure.
createSagepilotCameraXFilePicker() returns undefined outside Android, so cross-platform apps can call it from shared configuration code. On Android it exposes the CameraX camera source plus the addon native module's photo-library and document sources when they are linked in the host app.
iOS does not use this Android addon. If you pass createSagepilotCameraXFilePicker() from shared setup code on iOS, it returns undefined and the hosted widget uses WKWebView's native file input sheet unless your app provides a separate iOS picker through the base SDK.
Options
createSagepilotCameraXFilePicker({
imageMaxDimension: 1920,
imageQuality: 0.8,
imageMaxFileSizeBytes: 15 * 1024 * 1024,
documentMaxFileSizeBytes: 20 * 1024 * 1024,
includeLibrary: true,
includeDocuments: true
});