qtrust-scanner-react-native
v1.2.5
Published
QTrust cloud QR & barcode scanner for React Native
Maintainers
Readme
qtrust-scanner-react-native
QTrust on-device QR & barcode scanner for React Native. Mirrors the Flutter/iOS/Android SDKs. No server URL — scanning runs entirely on the device.
Install
npm install qtrust-scanner-react-native react-native-webview
cd ios && pod installBare React Native or an Expo dev-build / prebuild. Not Expo Go (native code).
Permissions
The host app must hold OS camera permission before mounting the view.
- Android:
<uses-permission android:name="android.permission.CAMERA" />and request at runtime. - iOS:
NSCameraUsageDescriptioninInfo.plist. - Expo: add the config plugin to
app.json:{ "expo": { "plugins": ["qtrust-scanner-react-native"] } }
Usage
import { QtrustScannerView, ScanType } from 'qtrust-scanner-react-native';
<QtrustScannerView
style={{ flex: 1 }}
config={{}}
type={ScanType.Qr}
onResult={(r) => console.log(r.data, r.format)}
onError={(e) => console.log(e.kind, e.message)}
/>Architecture support
The view is a SimpleViewManager (Android) / RCTViewManager (iOS). A
codegenNativeComponent spec ships and falls back to requireNativeComponent
under the Old Architecture.
Android emits events through the EventDispatcher, which delivers on both the
Old Architecture (Paper) and the New Architecture (Fabric, via the interop layer).
iOS surfaces events through RCTDirectEventBlock, carried by the Fabric interop
layer when the New Architecture is enabled.
Note: This package is not yet a fully native Fabric component (no Fabric C++/codegen native implementation). Under the New Architecture it runs through the RN interop layer for Paper view managers. A native Fabric implementation is a possible future enhancement.
API
| Prop | Type | Notes |
|---|---|---|
| config | ScannerConfig | { vendorConfig? } |
| type | ScanType | Qr (0) or Barcode (1) |
| onResult | (r: ScanResult) => void | { data, format, boundingBox } |
| onError | (e: ScannerError) => void | { kind, message } |
| onReady | () => void | scanner connected |
| onClose | () => void | closed from web UI |
