Infinity Plugin API Reference
This page documents all methods and event streams available in the Anyline Infinity Plugin.
Overview
-
Cordova
| Method | Description | Returns |
|---|---|---|
|
Initializes the Anyline SDK with a license key |
|
|
Starts a scan session with a |
|
|
Stops the active scan session |
|
|
Switches scan mode using a full scan-start request |
|
|
Switches scan mode using a raw |
|
|
Submits a User Corrected Result report |
|
|
Exports cached scan events as a ZIP archive |
|
|
Returns the plugin version string |
|
|
Returns the native SDK version string |
|
| Event Callback | Description |
|---|---|
|
Receives scan results during an active session (0..N). Passed as part of the |
|
Receives UI feedback element tap events (0..N). Passed as part of the |
Methods
All request and response types use the WrapperSession prefix (e.g. WrapperSessionScanStartRequest, WrapperSessionScanResponse). These are generated from the Anyline JSON schemas and represent the structured data exchanged between your application and the native SDK.
requestSdkInitialization
Initializes the Anyline SDK. Call this before starting any scan session.
Parameters:
-
request: aWrapperSessionSdkInitializationRequestcontaining your license key and optional configuration
Returns: WrapperSessionSdkInitializationResponse. See the overview table for platform-specific return type details.
-
Cordova
var request = {
licenseKey: 'YOUR_LICENSE_KEY', // Replace with your Anyline License Key
// Optional: only needed if your app bundles custom ML model files provided by Anyline.
// The value depends on where these files are placed in your project. See the Developer Examples.
assetPathPrefix: 'www/assets/anyline_assets',
};
anylineInfinity.requestSdkInitialization(
request,
function(response) {
if (response.initialized) {
console.log('SDK initialized:', response.succeedInfo);
} else {
console.error('SDK init failed:', response.failInfo.lastError);
}
},
function(error) {
console.error('SDK init error:', error);
}
);
requestScanStart
Starts a scan session. The method resolves/completes when the session ends (user dismissal, error, or programmatic stop). Intermediate scan results arrive via the onScanResults event stream.
Parameters:
-
request: aWrapperSessionScanStartRequestcontaining thescanViewConfigContentString(JSON)
Returns: WrapperSessionScanResponse when the session ends. See the overview table for platform-specific return type details.
-
Cordova
// Enums are available via window.AnylineEnums (merged by plugin.xml)
var ExportedScanResultImageFormat = AnylineEnums.ExportedScanResultImageFormat;
// Specify image format and delivery method for scan results
var scanResultConfig = {
imageContainer: {
encoded: {},
},
imageParameters: {
format: ExportedScanResultImageFormat.Png,
quality: 50,
},
};
// scanViewConfigJson is a JSON string containing your ScanViewConfig
var request = {
scanViewConfigContentString: scanViewConfigJson,
scanResultConfig: scanResultConfig,
};
anylineInfinity.requestScanStart(
request,
function(response) {
// Called once when the scan session ends
console.log('Scan session ended:', response.status);
},
{
onScanResults: function(result) {
// Called 0..N times during scanning
var scanResult = result.exportedScanResults && result.exportedScanResults[0];
console.log('Scan result:', scanResult && scanResult.pluginResult);
},
}
);
requestScanStop
Stops the active scan session.
Parameters:
-
request(optional): aWrapperSessionScanStopRequestwith stop configuration
Returns: No return value. See the overview table for platform-specific details.
-
Cordova
// Stop with default behavior
anylineInfinity.requestScanStop();
// Or stop with an optional reason (surfaces in abortInfo.message on the scan response)
anylineInfinity.requestScanStop({ message: 'Scan stopped: no result within timeout' });
requestScanSwitchWithScanStartRequestParams
Switches to a new scan mode without stopping the current session. Uses a full WrapperSessionScanStartRequest allowing you to change all scan parameters.
Parameters:
-
request: aWrapperSessionScanStartRequestwith the new configuration
Returns: No return value. See the overview table for platform-specific details.
Code examples for both switch methods are shown below.
requestScanSwitchWithScanViewConfigContentString
Switches to a new scan mode using only a raw ScanViewConfig JSON string. Use this when you only need to change the scan configuration without modifying other request parameters.
Parameters:
-
scanViewConfigContentString: a raw JSON string containing the newScanViewConfig
Returns: No return value. See the overview table for platform-specific details.
-
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,
);
requestUCRReport
Submits a User Corrected Result (UCR) report. UCR allows you to send corrections for scan results back to Anyline for model improvement.
Parameters:
-
request: aWrapperSessionUcrReportRequestcontaining the corrected result data
Returns: WrapperSessionUcrReportResponse. See the overview table for platform-specific return type details.
-
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);
}
);
requestExportCachedEvents
Exports all cached scan events as a ZIP archive. Useful for debugging or offline analytics.
Parameters: none
Returns: WrapperSessionExportCachedEventsResponse. See the overview table for platform-specific return type details.
-
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);
}
);
getPluginVersion
Returns the version string of the wrapper plugin itself.
Parameters: none
Returns: Version string. See the overview table for platform-specific return type details.
getSDKVersion
Returns the version string of the underlying native Anyline SDK.
Parameters: none
Returns: Version string. See the overview table for platform-specific return type details.
-
Cordova
// Get the plugin version
anylineInfinity.getPluginVersion(
function(version) {
console.log('Plugin version:', version);
},
function(error) {
console.error(error);
}
);
// Get the native SDK version
anylineInfinity.getSDKVersion(
function(version) {
console.log('SDK version:', version);
},
function(error) {
console.error(error);
}
);
Event Streams
onScanResults
Emits WrapperSessionScanResultsResponse objects during an active scan session. You may receive zero or more results before the session ends.
Subscribe to this event stream before calling requestScanStart.
See Scan Result Handling for details on the result structure.
-
Cordova
Scan results are delivered through the callbacks object passed to requestScanStart:
anylineInfinity.requestScanStart(
request,
onScanResponse,
{
onScanResults: function(result) {
// Iterate over all results in this batch (may contain multiple when using composite scanning)
var scanResults = result.exportedScanResults || [];
scanResults.forEach(function(scanResult) {
var pluginResult = scanResult.pluginResult;
console.log('Plugin result:', pluginResult);
// Handle images based on delivery method
var imageContainer = scanResult.imageContainer;
if (imageContainer && imageContainer.saved) {
var saved = imageContainer.saved;
var basePath = saved.path || '';
var fullFramePath = basePath + '/' + (saved.images && saved.images.image);
var cutoutPath = basePath + '/' + (saved.images && saved.images.cutoutImage);
} else if (imageContainer && imageContainer.encoded) {
var encoded = imageContainer.encoded;
// Decode from Base64 for display or upload
var fullFrameBase64 = encoded.images && encoded.images.image;
var cutoutBase64 = encoded.images && encoded.images.cutoutImage;
}
});
},
}
);
In Cordova, scan result events are multiplexed through the same cordova.exec channel as the scan response. The plugin demultiplexes them automatically.
|
onUIElementClicked
Emits UiFeedbackElementConfig objects when the user taps a UI feedback element during scanning. This is useful for interactive scan overlays.
See UI Feedback Config for details on configuring UI feedback elements.
-
Cordova
Pass an onUIElementClicked handler in the callbacks object of requestScanStart:
anylineInfinity.requestScanStart(
scanRequest,
function(response) { /* session ended */ },
{
onScanResults: function(results) { /* ... */ },
onUIElementClicked: function(element) {
console.log('UI element tapped:', element.id);
},
}
);