Compare commits

..
Author SHA1 Message Date
Daniel Sogl d0440b8558 feat(genius-scan): add barcode scanning and sync ScanConfiguration/result types with 6.3.0
Add scanBarcodesWithConfiguration() plus BarcodeConfiguration/BarcodeResult types,
and add ScanConfiguration fields (availableFilters, skipPostProcessingScreen,
defaultCurvatureCorrection, showCropValidation, defaultScanOrientation,
photoLibraryButtonHidden, structuredData, structuredDataBarcodeTypes,
requiredReadabilityLevel, pdfPassword, showFinalReview) that shipped upstream.
2026-07-27 22:22:26 +02:00
2 changed files with 126 additions and 202 deletions
@@ -40,7 +40,15 @@ export class GeniusScan extends AwesomeCordovaNativePlugin {
}
@Cordova()
scanWithConfiguration(configuration: ScanConfiguration): Promise<SuccessScanResult> {
scanWithConfiguration(configuration?: ScanConfiguration): Promise<SuccessScanResult> {
return;
}
/**
* Starts the barcode scanner module.
*/
@Cordova()
scanBarcodesWithConfiguration(configuration?: BarcodeConfiguration): Promise<BarcodeResult> {
return;
}
@@ -74,15 +82,31 @@ interface ScanConfiguration {
multiPageFormat?: 'pdf' | 'tiff' | 'none';
/**
* (by default, the filter is chosen automatically)
* The filter that will be applied by default to enhance scans, or 'none' if no
* enhancement should be performed by default. Possible values include 'automatic',
* 'automaticColor', 'automaticBlackAndWhite', 'automaticMonochrome', 'photo',
* 'softBlackAndWhite', 'softColor', 'strongMonochrome', 'strongBlackAndWhite',
* 'strongColor', 'darkBackground' and 'none' (defaults to 'automatic').
*/
defaultFilter?: 'none' | 'blackAndWhite' | 'monochrome' | 'color' | 'photo';
defaultFilter?: string;
/**
* an array of filters that the user can select when they tap on the edit filter button.
* Defaults to ['none', 'automatic', 'automaticMonochrome', 'automaticBlackAndWhite', 'automaticColor', 'photo'].
*/
availableFilters?: string[];
/**
* defaults to fit
*/
pdfPageSize?: 'fit' | 'a4' | 'letter';
/**
* Optional password used to protect generated PDF documents. Empty passwords are
* treated as no password. Only applies when multiPageFormat is 'pdf'.
*/
pdfPassword?: string;
/**
* max dimension in pixels when images are scaled before PDF generation,
* for example 2000 to fit both height and width within 2000px.
@@ -103,12 +127,42 @@ interface ScanConfiguration {
*/
jpegQuality?: number;
/**
* Whether to skip showing the post-processing screen. Only recommended when
* scanning structured data; generally the user should visually confirm each scan.
*/
skipPostProcessingScreen?: boolean;
/**
* an array with the desired actions to display during the post processing screen
* (defaults to all actions).
*/
postProcessingActions?: ('rotate' | 'editFilter' | 'correctDistortion')[];
/**
* whether a curvature correction should be applied by default (defaults to 'disabled').
*/
defaultCurvatureCorrection?: 'enabled' | 'disabled';
/**
* automatically show crop validation after capture. 'never', 'always', or an object
* with a confidence threshold below which validation should be shown.
*/
showCropValidation?:
'never' | 'always' | { whenConfidenceBelowOrEqual: 'lowest' | 'low' | 'medium' | 'high' | 'highest' };
/**
* 'automatic' to rotate scan automatically after capture or 'original' to keep the
* original scan orientation (defaults to 'automatic').
*/
defaultScanOrientation?: 'automatic' | 'original';
/**
* whether the button allowing the user to pick an image on the Camera screen
* should be hidden (defaults to false).
*/
photoLibraryButtonHidden?: boolean;
/**
* (default to false)
*/
@@ -160,13 +214,68 @@ interface ScanConfiguration {
*/
outputFormats?: ('rawText' | 'hOCR' | 'textLayerInPDF')[];
};
/**
* an array of the structured data you want to extract. E.g.: ['receipt', 'businessCard'].
* Possible values are 'receipt', 'barcode', 'bankDetails' (iOS only), 'businessCard' (iOS only).
*/
structuredData?: string[];
/**
* an array of the barcode types to extract, e.g. ['qr', 'code39']. Possible values are
* 'aztec', 'code39', 'code93', 'code128', 'dataMatrix', 'ean8', 'ean13', 'itf', 'pdf417',
* 'qr', 'upca' (Android only), 'upce', 'codabar' (iOS 15+ only), 'gs1DataBar' (iOS 15+ only),
* 'microPDF417' (iOS 15+ only), 'microQR' (iOS 15+ only), 'msiPlessey' (iOS 17+ only).
*/
structuredDataBarcodeTypes?: string[];
/**
* the required readability level below which a warning will be displayed to the user
* (defaults to 'lowest', which means the warning will never be displayed).
*/
requiredReadabilityLevel?: 'lowest' | 'low' | 'medium' | 'high' | 'highest';
/**
* whether the final review screen should be displayed before submission (default to false).
*/
showFinalReview?: boolean;
}
interface BarcodeConfiguration {
/**
* whether the barcode scanner should keep scanning and accumulating results after
* detecting a first barcode.
*/
isBatchModeEnabled?: boolean;
/**
* an array of the barcode types to detect. Defaults to all supported types.
*/
supportedCodeTypes?: string[];
}
interface BarcodeResult {
/**
* an array of the detected barcodes.
*/
barcodes: {
/**
* the decoded value of the barcode.
*/
value: string;
/**
* the type of the barcode, e.g. 'qr', 'code128'.
*/
type: string;
}[];
}
interface SuccessScanResult {
/**
* a document containing all the scanned pages (example: "file://.pdf")
*/
multiPageDocumentUrl: string;
multiPageDocumentUrl?: string;
/**
* an array of scan objects.
@@ -183,9 +292,9 @@ interface SuccessScanResult {
enhancedUrl: string;
/**
* the result of text recognition for this scan
* the result of text recognition for this scan, present when ocrConfiguration was set.
*/
ocrResult: {
ocrResult?: {
/**
* the raw text that was recognized
*/
@@ -194,8 +303,14 @@ interface SuccessScanResult {
/**
* the recognized text in hOCR format (with position, style…)
*/
hocrTextLayout: string;
hocrTextLayout?: string;
};
/**
* the result of the structured data extraction, present when structuredData was set.
* A subdictionary is present for each type of structured data detected.
*/
structuredData?: any;
}[];
}
@@ -209,7 +324,7 @@ interface GenerateDocumentPages {
/**
* the text layout in hOCR format
*/
hocrTextLayout: string;
hocrTextLayout?: string;
}[];
}
@@ -9,9 +9,6 @@ export type Event =
| 'notificationTapped'
| 'tokenReceived'
| 'registrationUpdated'
/**
* @deprecated No longer part of the supported events list in the upstream SDK (confirmed absent as of v8.6.0, and as far back as v5.0.0).
*/
| 'geofenceEntered'
| 'actionTapped'
| 'installationUpdated'
@@ -21,9 +18,6 @@ export type Event =
| 'inAppChat.availabilityUpdated'
| 'inAppChat.unreadMessageCounterUpdated'
| 'deeplink'
/**
* @deprecated No longer part of the supported events list in the upstream SDK (confirmed absent as of v8.6.0, and as far back as v5.0.0).
*/
| 'inAppChat.viewStateChanged';
export interface CustomEvent {
@@ -40,14 +34,6 @@ export interface Configuration {
geofencingEnabled?: boolean;
inAppChatEnabled?: boolean;
fullFeaturedInAppsEnabled?: boolean | undefined;
/**
* Set to true to enable debug logging.
*/
loggingEnabled?: boolean;
/**
* List of trusted domain strings for web views, e.g. ['example.com', 'trusted.org']
*/
trustedDomains?: string[];
/**
* Message storage save callback
*/
@@ -56,40 +42,12 @@ export interface Configuration {
ios?: {
notificationTypes?: string[]; // ['alert', 'badge', 'sound']
forceCleanup?: boolean;
/**
* @deprecated Removed upstream in v7.3.0. Replaced by the top-level `loggingEnabled` option.
*/
logging?: boolean;
/**
* Set to true to disable automatic registration for remote notifications. Default: false
*/
registeringForRemoteNotificationsDisabled?: boolean;
/**
* Set to true to prevent the SDK from overriding UNUserNotificationCenterDelegate. Default: false
*/
overridingNotificationCenterDelegateDisabled?: boolean;
/**
* Set to true to prevent the SDK from unregistering for remote notifications when stopping the SDK or after depersonalization. Default: false
*/
unregisteringForRemoteNotificationsDisabled?: boolean;
/**
* Settings for web view configuration in in-app messages
*/
webViewSettings?: {
title?: string;
barTintColor?: string;
titleColor?: string;
tintColor?: string;
};
};
android?: {
notificationIcon?: string; // a resource name for a status bar icon (without extension), located in '/platforms/android/app/src/main/res/mipmap'
notificationChannelId?: string; // identifier for notification channel
notificationChannelName?: string; // user visible name for notification channel
notificationSound?: string; // a resource name for a notification sound (without extension), located in '/platforms/android/app/src/main/res/raw'
multipleNotifications?: boolean; // set to 'true' to enable multiple notifications
notificationAccentColor?: string; // set to hex color value in format '#RRGGBB' or '#AARRGGBB'
withBannerForegroundNotificationsEnabled?: boolean; // set to true to always display Push notifications as Banner
firebaseOptions?: {
apiKey: string;
applicationId: string;
@@ -120,9 +78,9 @@ export interface Configuration {
icon?: string;
textInputActionButtonTitle?: string;
textInputPlaceholder?: string;
},
}
];
},
}
];
}
@@ -152,14 +110,7 @@ export interface Installation {
deviceModel?: string;
deviceSecure?: boolean;
language?: string;
/**
* @deprecated Renamed upstream in v7.9.1 to `deviceTimezoneOffset`.
*/
deviceTimezoneId?: string;
/**
* UTC-related timezone offset that identifies the current timezone of a device.
*/
deviceTimezoneOffset?: string;
applicationUserId?: string;
deviceName?: string;
customAttributes?: Record<string, string | number | boolean>;
@@ -178,14 +129,6 @@ export interface PersonalizeContext {
userIdentity: UserIdentity;
userAttributes?: Record<string, string | number | boolean | any[]>;
forceDepersonalize?: boolean;
/**
* Set to true if you want to keep the installation as a lead when personalizing it. Default: false
*/
keepAsLead?: boolean;
/**
* Set to true to mark this installation as primary for the personalized user. Default: false
*/
setDeviceAsPrimary?: boolean;
}
export interface GeoData {
@@ -333,17 +276,6 @@ export interface ChatSettingsIOS {
navigationBarTitleColor: string;
}
/**
* Exception raised by the in-app chat widget and passed to the handler registered via `setChatExceptionHandler`.
*/
export interface ChatException {
code: string;
name: string;
message: string;
origin: string;
platform: string;
}
/**
* @name Mobile Messaging
* @description
@@ -733,7 +665,7 @@ export class MobileMessaging extends AwesomeCordovaNativePlugin {
/**
* Updates JWT used for user data fetching and personalization.
*
*
* @name setUserDataJwt
* @param jwt - JWT in a predefined format
* @param {Function} errorCallback will be called on error
@@ -742,127 +674,4 @@ export class MobileMessaging extends AwesomeCordovaNativePlugin {
setUserDataJwt(jwt: string, errorCallback?: (error: MobileMessagingError) => void) {
return;
}
/**
* Un register all handlers for a MobileMessaging library event.
*
* @name unregisterAllHandlers
* @param event
*/
@Cordova({
sync: true,
})
unregisterAllHandlers(event: Event): void {
return;
}
/**
* Sets the JWT provider used to authenticate in-app chat sessions.
*
* The `jwtProvider` callback returns a JSON Web Token (JWT) used for chat authentication,
* either synchronously (returning a string) or asynchronously (returning a Promise<string>).
* It may be invoked multiple times during the widget's lifecycle, so it should always return
* a fresh and valid JWT.
*
* @param jwtProvider A callback function that returns a JWT string or a Promise that resolves to one.
* @param errorCallback Optional error handler for catching exceptions thrown during JWT generation.
*/
@Cordova({
sync: true,
})
setChatJwtProvider(jwtProvider: () => string | Promise<string>, errorCallback?: (error: any) => void): void {
return;
}
/**
* Sets the chat exception handler in case you want to intercept and display errors coming
* from the chat on your own (instead of relying on the prebuilt error banners).
* Passing `null` removes the previously set handler.
*
* @param exceptionHandler A function called with the chat exception when it is triggered, or `null` to remove the handler.
* @param errorCallback Optional error handler for catching exceptions thrown when handling exceptions from the native side.
*/
@Cordova({
sync: true,
})
setChatExceptionHandler(
exceptionHandler: ((exception: ChatException) => void) | null,
errorCallback?: (error: any) => void
): void {
return;
}
/**
* Checks if in-app chat is currently available.
*
* @name isChatAvailable
* @param resultCallback will be called upon completion with the boolean availability value.
*/
@Cordova({ sync: true })
isChatAvailable(resultCallback: (available: boolean) => void): void {
return;
}
/**
* Sets chat language.
*
* @name setLanguage
* @param language to be set
* @param {Function} errorCallback will be called on error
*/
@Cordova()
setLanguage(language: string, errorCallback?: (error: MobileMessagingError) => void) {
return;
}
/**
* Set contextual data of the widget.
*
* @param data contextual data in the form of a JSON string
* @param allMultiThreadStrategy multi-thread strategy flag, true -> ALL, false -> ACTIVE
* @param {Function} errorCallback will be called on error
*/
@Cordova()
sendContextualData(
data: string,
allMultiThreadStrategy: boolean,
errorCallback?: (error: MobileMessagingError) => void
) {
return;
}
/**
* Cleans up the SDK, removing all data and stopping all services.
* After cleanup, you should call `init()` again with a new configuration to restart the SDK.
* The JWT supplier is also cleared during cleanup.
*
* @name cleanup
*/
@Cordova()
cleanup(): Promise<any> {
return;
}
/**
* Sets chat customization.
*
* @name setChatCustomization
* @param customization Chat customization JSON object.
*/
@Cordova()
setChatCustomization(customization: any): Promise<any> {
return;
}
/**
* Sets widget theme.
*
* @name setWidgetTheme
* @param widgetTheme Widget theme name.
* @param {Function} errorCallback will be called on error
*/
@Cordova()
setWidgetTheme(widgetTheme: string, errorCallback?: (error: MobileMessagingError) => void) {
return;
}
}