Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 1c27454

Browse files
authored
Merge pull request #3 from blinkinput/release/v4.2.0
Release/v4.3.0
2 parents 30b3539 + dbf6a03 commit 1c27454

126 files changed

Lines changed: 6134 additions & 64 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,13 @@
1-
# Xcode
2-
#
3-
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4-
5-
## User settings
6-
xcuserdata/
7-
8-
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
9-
*.xcscmblueprint
10-
*.xccheckout
1+
# OSX
2+
.DS_Store
113

12-
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
4+
# Xcode
135
build/
14-
DerivedData/
15-
*.moved-aside
166
*.pbxuser
177
!default.pbxuser
18-
*.mode1v3
19-
!default.mode1v3
20-
*.mode2v3
21-
!default.mode2v3
22-
*.perspectivev3
23-
!default.perspectivev3
24-
25-
## Obj-C/Swift specific
26-
*.hmap
27-
28-
## App packaging
29-
*.ipa
30-
*.dSYM.zip
31-
*.dSYM
32-
33-
# CocoaPods
34-
#
35-
# We recommend against adding the Pods directory to your .gitignore. However
36-
# you should judge for yourself, the pros and cons are mentioned at:
37-
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
38-
#
39-
# Pods/
40-
#
41-
# Add this line if you want to avoid checking in source code from the Xcode workspace
42-
# *.xcworkspace
43-
44-
# Carthage
45-
#
46-
# Add this line if you want to avoid checking in source code from Carthage dependencies.
47-
# Carthage/Checkouts
48-
49-
Carthage/Build/
50-
51-
# fastlane
52-
#
53-
# It is recommended to not store the screenshots in the git repo.
54-
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
55-
# For more information about the recommended setup visit:
56-
# https://docs.fastlane.tools/best-practices/source-control/#source-control
57-
58-
fastlane/report.xml
59-
fastlane/Preview.html
60-
fastlane/screenshots/**/*.png
61-
fastlane/test_output
628

63-
# Code Injection
64-
#
65-
# After new code Injection tools there's a generated folder /iOSInjectionProject
66-
# https://github.com/johnno1962/injectionforxcode
9+
xcuserdata
10+
xcshareddata
6711

68-
iOSInjectionProject/
12+
#Demo App
13+
/BlinkInputReactNative
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4+
5+
Pod::Spec.new do |s|
6+
s.name = package['name']
7+
s.version = package['version']
8+
s.summary = package['description']
9+
10+
s.authors = package['author']
11+
s.homepage = package['homepage']
12+
s.license = package['license']
13+
s.platform = :ios, "9.0"
14+
15+
s.source = { :git => "https://github.com/BlinkInput/blinkinput-react-native.git", :tag => "v#{s.version}" }
16+
s.source_files = "src/ios", "src/ios/**/*.{h,m}"
17+
s.header_dir = "blinkinput-react-native"
18+
19+
s.dependency 'React'
20+
s.dependency 'PPBlinkOCR', '~> 4.3.0'
21+
22+
s.frameworks = 'UIKit'
23+
end

BlinkInput/index.js

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
'use strict';
2+
3+
import { Platform, NativeModules } from 'react-native';
4+
5+
import { RecognizerResultState } from './recognizer'
6+
7+
const BlinkInputNative = Platform.select({
8+
ios: NativeModules.BlinkInputIos,
9+
android: NativeModules.BlinkInputAndroid
10+
})
11+
12+
/**
13+
* This exposes the appropriate native BlinkInput module module as a JS module, based on
14+
* detected platform: Android or iOS. This has functions:
15+
* -> 'scanWithCamera' which takes the following parameters:
16+
* 1. Object overlaySettings: instance of OverlaySettings, contains settings for desired camera overlay
17+
* 2. RecognizerCollection recognizerCollection: object containing recognizers to use for scanning
18+
* 3. String license: BlinkInput base64 license key bound to application ID for Android or iOS. To obtain
19+
* valid license key, please visit http://microblink.com/login or
20+
* contact us at http://help.microblink.com
21+
*
22+
* OR
23+
*
24+
* Object license: containing:
25+
* - mandatory parameter 'licenseKey': base64 license key bound to application ID
26+
* for Android or iOS. To obtain valid license key, please visit
27+
* http://microblink.com/login or contact us at http://help.microblink.com
28+
* - optioanl parameter 'licensee' when license for multiple apps is used
29+
* - optional flag 'showTimeLimitedLicenseKeyWarning' which indicates
30+
* whether warning for time limited license key will be shown
31+
* in format
32+
* {
33+
* licenseKey: '<base64iOSLicense or base64AndroidLicense>',
34+
* licensee: String,
35+
* showTimeLimitedLicenseKeyWarning: Boolean
36+
* }
37+
* -> 'captureDocument' which takes following parameters:
38+
* 1. DocumentCaptureRecognizer documentCaptureRecognizer: object containing settings for document capture recognizer
39+
* 2. String license: the same as 'license' for 'scanWithCamera' function
40+
*/
41+
class BlinkInputWrapper {
42+
async scanWithCamera(overlaySettings, recognizerCollection, license) {
43+
try {
44+
var bla = NativeModules;
45+
console.log(bla);
46+
var licenseObject = license;
47+
if (typeof license === 'string' || license instanceof String) {
48+
licenseObject = { licenseKey: license };
49+
}
50+
const nativeResults = await BlinkInputNative.scanWithCamera(overlaySettings, recognizerCollection, licenseObject);
51+
if (nativeResults.length != recognizerCollection.recognizerArray.length) {
52+
console.log("INTERNAL ERROR: native plugin returned wrong number of results!");
53+
return [];
54+
} else {
55+
let results = [];
56+
for (let i = 0; i < nativeResults.length; ++i) {
57+
// native plugin must ensure types match
58+
// recognizerCollection.recognizerArray[i].result = recognizerCollection.recognizerArray[i].createResultFromNative(nativeResults[i]);
59+
60+
// unlike Cordova, ReactNative does not allow mutation of user-provided recognizers, so we need to
61+
// return results and let user handle them manually.
62+
let result = recognizerCollection.recognizerArray[i].createResultFromNative(nativeResults[i]);
63+
if (result.resultState != RecognizerResultState.empty) {
64+
results.push(result);
65+
}
66+
}
67+
return results;
68+
}
69+
} catch (error) {
70+
console.log(error);
71+
return [];
72+
}
73+
}
74+
async captureDocument(documentCaptureRecognizer, license) {
75+
try {
76+
var licenseObject = license;
77+
if (typeof license === 'string' || license instanceof String) {
78+
licenseObject = { licenseKey: license };
79+
}
80+
const nativeDocumentCaptureResult = await BlinkInputNative.captureDocument(documentCaptureRecognizer, licenseObject);
81+
82+
return new DocumentCaptureResult(nativeDocumentCaptureResult);
83+
} catch (error) {
84+
console.log(error);
85+
return [];
86+
}
87+
}
88+
async scanWithFieldByField(fieldByFieldCollection, license) {
89+
try {
90+
var licenseObject = license;
91+
if (typeof license === 'string' || license instanceof String) {
92+
licenseObject = { licenseKey: license };
93+
}
94+
const nativeFieldByFieldResult = await BlinkInputNative.scanWithFieldByField(fieldByFieldCollection, licenseObject);
95+
96+
let results = [];
97+
for (let i = 0; i < nativeFieldByFieldResult.length; ++i) {
98+
let result = new FieldByFieldResult(nativeFieldByFieldResult[i]);
99+
results.push(result);
100+
}
101+
return results;
102+
} catch (error) {
103+
console.log(error);
104+
return [];
105+
}
106+
}
107+
}
108+
109+
export var BlinkInput = new BlinkInputWrapper();
110+
111+
import { Recognizer } from './recognizer'
112+
113+
/**
114+
* Represents a collection of recognizer objects.
115+
*/
116+
export class RecognizerCollection {
117+
/**
118+
*
119+
* @param recognizerArray Array of recognizer objects that will be used for recognition. Must not be empty!
120+
*/
121+
constructor(recognizerArray) {
122+
/** Array of recognizer objects that will be used for recognition */
123+
this.recognizerArray = recognizerArray;
124+
/**
125+
* Whether or not it is allowed for multiple recognizers to process the same image.
126+
* If not, then first recognizer that will be successful in processing the image will
127+
* end the processing chain and other recognizers will not get the chance to process
128+
* that image.
129+
*/
130+
this.allowMultipleResults = false;
131+
/** Number of miliseconds after first non-empty result becomes available to end scanning with a timeout */
132+
this.milisecondsBeforeTimeout = 10000;
133+
134+
if (!(this.recognizerArray instanceof Array)) {
135+
throw new Error("recognizerArray must be array of Recognizer objects!");
136+
}
137+
// ensure every element in array is Recognizer
138+
for (var i = 0; i < this.recognizerArray.length; ++i) {
139+
if (!(this.recognizerArray[i] instanceof Recognizer )) {
140+
throw new Error( "Each element in recognizerArray must be instance of Recognizer" );
141+
}
142+
}
143+
}
144+
}
145+
146+
import { Parser } from './parser'
147+
148+
/**
149+
* Represents a collection of scane elements
150+
*/
151+
export class FieldByFieldCollection {
152+
/**
153+
*
154+
* @param fieldByFieldElementArray Array of field by field elements objects that will be used for recognition. Must not be empty!
155+
*/
156+
constructor(fieldByFieldElementArray) {
157+
/** Array of recognizer objects that will be used for recognition */
158+
this.fieldByFieldElementArray = fieldByFieldElementArray;
159+
160+
if (!(this.fieldByFieldElementArray instanceof Array)) {
161+
throw new Error("recognizerArray must be array of Recognizer objects!");
162+
}
163+
// ensure every element in array is Recognizer
164+
for (var i = 0; i < this.fieldByFieldElementArray.length; ++i) {
165+
if (!(this.fieldByFieldElementArray[i] instanceof FieldByFieldElement )) {
166+
throw new Error( "Each element in fieldByFieldElementArray must be instance of FieldByFieldElement" );
167+
}
168+
}
169+
}
170+
}
171+
172+
export class FieldByFieldElement {
173+
constructor(identifier, parser, localizedTitle, localizedTooltip) {
174+
/**
175+
* Unique name of the element
176+
*/
177+
this.identifier = identifier;
178+
179+
/**
180+
Parser object which is reponsible scanning the text.
181+
*/
182+
this.parser = parser;
183+
184+
/**
185+
* Localized title (used in the Pivot control)
186+
*/
187+
this.localizedTitle = localizedTitle;
188+
189+
/**
190+
* Localized tooltip (used in the tooltip label above the viewfinder)
191+
*/
192+
this.localizedTooltip = localizedTooltip;
193+
194+
if (!(this.parser instanceof Parser)) {
195+
throw new Error("Parser must be instance of Parser!");
196+
}
197+
}
198+
}
199+
200+
export class FieldByFieldResult {
201+
constructor(nativeFieldByFieldResult) {
202+
/**
203+
* Unique name of the element
204+
*/
205+
this.identifier = nativeFieldByFieldResult.identifier;
206+
207+
/**
208+
Value of parser object after scanning.
209+
*/
210+
this.value = nativeFieldByFieldResult.value;
211+
}
212+
}
213+
import { DocumentCaptureRecognizerResult } from './recognizers/documentCaptureRecognizer'
214+
/**
215+
* Represents a result of 'captureDocument' functionality.
216+
*/
217+
export class DocumentCaptureResult {
218+
constructor(nativeDocumentCaptureResult) {
219+
this.documentCaptureRecognizerResult = new DocumentCaptureRecognizerResult(nativeDocumentCaptureResult.documentCaptureRecognizerResult);
220+
this.capturedFullImage = nativeDocumentCaptureResult.capturedFullImage;
221+
}
222+
}
223+
224+
export { RecognizerResultState } from './recognizer'
225+
export * from './types'
226+
227+
// export overlays that can be used
228+
export * from './overlays/barcodeOverlays'
229+
230+
// export recognizers that can be used and their results
231+
export * from './recognizers/successFrameGrabberRecognizer'
232+
export * from './recognizers/barcodeRecognizer'
233+
export * from './recognizers/documentCaptureRecognizer'
234+
export * from './recognizers/pdf417Recognizer'
235+
export * from './recognizers/simNumberRecognizer'
236+
// export * from './recognizers/blinkInputRecognizer'
237+
238+
export { ParserResultState } from './parser'
239+
export { ProcessorResultState } from './processor'
240+
241+
// export parsers that can be used and their results
242+
export * from './parsers/amountParser'
243+
export * from './parsers/dateParser'
244+
export * from './parsers/emailParser'
245+
export * from './parsers/ibanParser'
246+
export * from './parsers/licensePlatesParser'
247+
export * from './parsers/rawParser'
248+
export * from './parsers/topUpParser'
249+
export * from './parsers/vinParser'
250+
export * from './parsers/regexParser'
251+
252+
// // export processors that can be used and their results
253+
// export * from './processors/parserGroupProcessor'
254+
//
255+

BlinkInput/overlaySettings.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/** Base class for all overlay settings objects */
2+
export class OverlaySettings {
3+
constructor(overlaySettingsType) {
4+
/** type of the overlay settings object */
5+
this.overlaySettingsType = overlaySettingsType;
6+
/** whether front camera should be used instead of the default camera */
7+
this.useFrontCamera = false;
8+
/** whether beep sound will be played on successful scan */
9+
this.enableBeep = false;
10+
/** (optional) if default overlay contains textual information, text will be localized to this language. Otherwise device langauge will be used */
11+
/** example: "en" */
12+
this.language = null;
13+
/** (optional) to be used with language variable, it defines the country locale */
14+
/** example: "US" to use "en_US" on Android and en-US on iOS */
15+
this.country = null;
16+
}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { OverlaySettings } from '../overlaySettings'
2+
3+
/**
4+
* Class for setting up barcode overlay.
5+
* Barcode overlay is best suited for recognizers that perform barcode scanning.
6+
*/
7+
export class BarcodeOverlaySettings extends OverlaySettings {
8+
constructor() {
9+
super('BarcodeOverlaySettings');
10+
}
11+
}

0 commit comments

Comments
 (0)