Advanced Topics
This page covers advanced Infinity Plugin features including UI configuration, native view integration, scan switching, User Corrected Results (UCR), event caching, and platform-specific considerations.
UI Configuration
The Infinity Plugin offers two approaches to customizing the scan view UI: ScanView Config Options for simple, built-in controls and UI Feedback Config for advanced, fully customizable overlays.
| Prefer UI Feedback Config over ScanView Config Options whenever possible. It provides finer positioning control, uniform presentation across Android and iOS, and the ability to respond dynamically to scan feedback events. |
ScanView Config Options
scanViewConfigOptions provides a set of pre-built UI controls that can be added to the scan view with minimal configuration. These are passed as a top-level JSON property alongside the scan start request.
-
defaultOrientation
-
toolbarTitle
-
segmentConfig
Sets the initial screen orientation when the scan view is presented. Values: portrait or landscape.
{
"options": {
"defaultOrientation": "landscape"
}
}
Title shown on the toolbar with a back button. Fullscreen scanning only. Ignored when using a ContainerView (NativeView mode).
{
"options": {
"toolbarTitle": "Scan Document"
}
}
A multi-mode segment control for switching between different scanning configurations (e.g., MRZ, Barcode, License Plate). Requires equal numbers of titles and viewConfigs.
{
"options": {
"segmentConfig": {
"titles": ["MRZ", "Barcode", "License Plate"],
"viewConfigs": ["mrz_config.json", "barcode_config.json", "license_plate_config.json"],
"titleIndex": 0,
"tintColor": "0099FF"
}
}
}
The viewConfigs entries reference ScanViewConfig JSON files in the assets folder, resolved relative to the scanViewConfigPath set in the WrapperSessionScanStartRequest.
|
For all available options and their properties, see the WrapperSessionScanViewConfigOptions schema reference.
UI Feedback Config
For more advanced UI customization, use the UI Feedback Config system. This allows you to define interactive overlay elements (labels, images) that respond to scan state changes and user interaction.
Key advantages over ScanView Config Options:
-
Fine-grained positioning: precise control over element placement, sizing, and layering
-
Cross-platform consistency: uniform rendering on both Android and iOS
-
Scan feedback integration: elements can react dynamically to scan events (e.g. insufficient lighting, incorrect distance from object)
-
Interactive elements: tappable elements emit events via
onUIElementClicked
See UI Feedback Config for the full configuration guide, UIFeedback Config Elements for all available element types, and the UI Feedback Config schema reference.
Native View Integration
The Infinity Plugin supports two presentation modes for the scan view: full-screen and embedded (NativeView). Support varies by platform.
| Feature | Flutter | React Native | Cordova |
|---|---|---|---|
Full-screen scanning |
✓ |
✓ |
✓ |
Embedded NativeView |
✓ |
✓ |
✗ |
Full-Screen Mode
In full-screen mode, calling requestScanStart launches a native Activity (Android) or ViewController (iOS) that takes over the entire screen. This is the simplest integration and works on all platforms.
Embedded NativeView Mode (Flutter & React Native)
In NativeView mode, the scan view is embedded directly in the app’s widget/component tree. This allows you to display scanning alongside other UI elements (e.g., a results list) and control the view’s size and position.
-
Cordova
Cordova does not support embedded native views due to its WebView-based architecture. Scanning always opens in full-screen mode.
Scan Switching
The Infinity Plugin supports switching scan modes without stopping and restarting the scan session.
Two methods are available:
-
requestScanSwitchWithScanStartRequestParams: switches using a fullWrapperSessionScanStartRequest, allowing you to change all scan parameters -
requestScanSwitchWithScanViewConfigContentString: switches using only a rawScanViewConfigJSON string, for simple configuration changes
Both methods are fire-and-forget: they do not return a response.
The correlationId parameter in scanViewInitializationParameters is an optional identifier you can set to group related scan operations in analytics and event exports.
-
Cordova
Switch to a new scan mode using a full scan-start request. For example, to change the scan configuration, save result images to a directory, and set a workflow correlationId:
var baseDir = cordova.file.documentsDirectory || cordova.file.dataDirectory;
var resultPath = baseDir.replace(/^file:\/\//, '').replace(/\/$/, '') + '/results/';
// newScanViewConfigJson: a JSON string containing the replacement ScanViewConfig
var switchRequest = {
scanViewConfigContentString: newScanViewConfigJson,
scanResultConfig: {
cleanStrategy: AnylineEnums.WrapperSessionScanResultCleanStrategyConfig.CleanFolderOnStartScanning,
imageContainer: {
saved: {
path: resultPath,
},
},
imageParameters: {
quality: 50,
format: 'png',
},
},
scanViewInitializationParameters: {
correlationId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
},
};
anylineInfinity.requestScanSwitchWithScanStartRequestParams(switchRequest);
Or switch using only a raw ScanViewConfig JSON string:
anylineInfinity.requestScanSwitchWithScanViewConfigContentString(
newScanViewConfigJson,
);
User Corrected Results (UCR)
UCR allows you to submit corrections for scan results back to Anyline. This feedback loop helps improve scanning accuracy over time.
| UCR is opt-in, and you decide how it is implemented in your app. Additionally, your Anyline License Key needs to have the relevant flag enabled for UCR. Please contact your CSM or Support for further information. |
After receiving a scan result, you can present it to the user for verification. If the user corrects any fields, submit the corrected data via requestUCRReport. The request requires the blobKey from the original scan result, a unique identifier that links the correction to the specific scan event on the Anyline backend.
-
Cordova
var UcrStatus = AnylineEnums.WrapperSessionUcrReportResponseStatus;
// pluginResult: obtained from the onScanResults event stream (see Scan Result Handling)
// userCorrectedValue: the value corrected by the user after reviewing the scan result
var ucrRequest = {
blobKey: pluginResult.blobKey,
correctedResult: userCorrectedValue,
};
anylineInfinity.requestUCRReport(
ucrRequest,
function(response) {
if (response.status === UcrStatus.UcrReportSucceeded) {
console.log('UCR submitted:', response.succeedInfo.message);
}
},
function(err) {
console.error('UCR failed:', err);
}
);
Exporting Cached Events
Your contact person at Anyline may request you to supply a log archive to track usage statistics. The Anyline Infinity Plugin provides the requestExportCachedEvents method to export cached scan events into a ZIP archive on the device filesystem. The method returns a response containing the filesystem path to the generated archive.
| Export of cached events ZIP generation can take up to several minutes depending on the number of recorded events. |
After exporting, retrieve the archive from the device and send it to your contact person at Anyline, as agreed to beforehand.
-
Cordova
var ExportStatus = AnylineEnums.WrapperSessionExportCachedEventsResponseStatus;
anylineInfinity.requestExportCachedEvents(
function(response) {
if (response.status === ExportStatus.ExportSucceeded) {
var filePath = response.succeedInfo.exportedFile;
console.log('Events exported to:', filePath);
}
},
function(err) {
console.error('Export failed:', err);
}
);
Platform-Specific Considerations
Cordova
-
The plugin is a singleton module. There is no
dispose()method. -
Event callbacks (
onScanResults,onUIElementClicked) are passed via thecallbacksobject inrequestScanStart, and are scoped to that session -
All asynchronous methods use the standard Cordova success/failure callback pattern
-
requestScanStartmultiplexes scan results and session-end responses through the samecordova.execchannel using typed payloads
Error Handling
All methods that interact with the native SDK can fail. Handle errors appropriately:
Cordova: Provide onFailure callbacks to all methods that accept them. The error object contains a lastError property with details.
anylineInfinity.requestScanStart(
request,
function(response) {
if (response.failInfo) {
console.error('Scan ended with error:', response.failInfo.lastError);
}
},
function(error) {
console.error('Scan start failed:', error.lastError);
}
);
Common error scenarios:
-
Invalid or expired license key
-
Camera permission not granted
-
Invalid
ScanViewConfigJSON -
Calling scan methods before SDK initialization
Next Steps
-
Schema Reference — configuration and result JSON schema reference
-
Infinity Plugin API Reference — complete method reference for the Infinity Plugin