Scan Result Handling
This page explains the structure of scan results, how to access result data and images, and best practices for result handling.
Result Structure
The SDK delivers scan results as WrapperSessionScanResultsResponse objects through the onScanResults event stream. Each response contains an array of ExportedScanResult objects, the structured representation of what the scanner detected, including the recognized data, confidence score, and optionally captured images.
Top-Level Fields
| Field | Type | Description |
|---|---|---|
|
List |
Array of |
|
Object |
The result configuration that was active during scanning |
|
Object |
Additional metadata about the scan results |
ExportedScanResult Fields
Each ExportedScanResult in the exportedScanResults array contains:
| Field | Type | Description |
|---|---|---|
|
Object |
The plugin-specific scan result (contains |
|
Object |
Image delivery container with |
|
Object |
Image format and quality settings used for export |
The pluginResult structure varies by plugin type. See PluginResult Documentation for the full schema definition.
Receiving Results
Subscribe to the onScanResults event stream to receive results. The listener below demonstrates iterating over results and handling images:
-
React Native
const subscription = infinityPlugin.onScanResults((result) => {
// Iterate over all results in this batch (may contain multiple when using composite scanning)
for (const scanResult of result.exportedScanResults ?? []) {
const pluginResult = scanResult.pluginResult;
console.log('Plugin result:', pluginResult);
// Handle images based on delivery method
const imageContainer = scanResult.imageContainer;
if (imageContainer?.saved) {
const saved = imageContainer.saved;
const basePath = saved.path ?? '';
const fullFramePath = `${basePath}/${saved.images?.image}`;
const cutoutPath = `${basePath}/${saved.images?.cutoutImage}`;
} else if (imageContainer?.encoded) {
const encoded = imageContainer.encoded;
// Decode from Base64 for display or upload
const fullFrameBase64 = encoded.images?.image;
const cutoutBase64 = encoded.images?.cutoutImage;
}
}
});
// Remove subscription when no longer needed
subscription.remove();
Image Handling
Scan results may include captured images, delivered via the imageContainer field on each ExportedScanResult. Images can be delivered as:
-
Encoded images (
imageContainer.encoded): Base64-encoded image data embedded in the result -
Saved images (
imageContainer.saved): file paths to images saved on disk, with apathfield for the directory andimagesfor the filenames
Configure image delivery via scanResultConfig.imageContainer in the WrapperSessionScanStartRequest.
Session End Response
When a scan session ends (via requestScanStop, user dismissal, or error), requestScanStart resolves with a WrapperSessionScanResponse. This response contains:
-
status: indicates how the session ended (scanSucceeded,scanAborted, orscanFailed) -
succeedInfo: populated when status isscanSucceeded -
abortInfo: populated when status isscanAborted, contains the abort reason -
failInfo: populated when status isscanFailed, contains the error details -
scanResultConfig: the result configuration that was active during the session
Next Steps
-
Advanced Topics — scan switching, UCR, cached events, native views, and error handling
-
Schema Reference — configuration and result JSON schema reference
-
Infinity Plugin API Reference — complete method reference for the Infinity Plugin