React Native
Camera Switching
The Vision SDK supports switching between front and back cameras on supported devices. This guide covers camera switching for both the VisionCamera and VisionSdkView components.
Platform Support
- iOS: Fully functional - Switches between front and back cameras seamlessly
- Android: Placeholder implementation - API is accepted but camera switching is not yet functional (awaiting VisionSDK Android support)
VisionCamera (Prop-based)
The VisionCamera component provides a simple prop-based API for camera switching using the cameraFacing prop.
Basic Implementation
Props
Type Export
VisionSdkView (Ref-based)
The VisionSdkView component uses an imperative API through the setCameraSettings method for camera switching.
Basic Implementation
Camera Position Values
Advanced Examples
VisionCamera with Camera Toggle Icon
VisionSdkView with State Management
Platform-Specific Behavior
iOS
On iOS, camera switching works seamlessly:
- Instant switching between cameras
- Maintains current scanning mode and settings
- No frame drops during transition
- Works with all scan modes (barcode, QR, OCR, photo)
Android
On Android, the camera switching API is a placeholder:
- API accepts the prop/parameter but doesn't switch cameras
- Awaiting underlying VisionSDK Android implementation
- Won't cause errors or crashes
- Forward compatible - will work once SDK supports it
Android Users: Camera switching is not yet functional on Android. The API is in place for forward compatibility. Your app won't crash, but the camera won't switch when the prop/method is called.
Comparison: VisionCamera vs VisionSdkView
For new projects, we recommend using VisionCamera with its prop-based API for a more React-friendly experience.
Best Practices
Always provide a UI control for camera switching - don't make users guess:
Show current camera state to the user:
Handle platform differences gracefully:
Preserve other camera settings when switching:
Troubleshooting
Camera doesn't switch on iOS
- Verify the prop/method value is actually changing
- Check device has both front and back cameras
- Ensure camera permissions are granted for both cameras
No effect on Android
- This is expected behavior - Android support coming soon
- Disable the toggle button or show a "Coming Soon" message
- Your app will automatically work once Android support is added
Camera feed freezes during switch
- This shouldn't happen on iOS - report as a bug
- Ensure you're not stopping/starting the camera during switch
Flash doesn't work on front camera
- Most devices don't have front-facing flash
- Consider adding a white screen flash effect for selfies
Related Documentation
- VisionCamera Component - Full VisionCamera documentation
- Props Reference - Complete props documentation