3.2.0 • Published 14h ago
react-native-okaycam
Licence
MIT
Version
3.2.0
Deps
1
Size
119 kB
Vulns
0
Weekly
0
Install scriptsThis package runs scripts during installation (preinstall/install/postinstall)
react-native-okaycam
Requirements
Android
- minSdkVersion >= 30
iOS
- iOS 15+
- Swift 5
Getting started
$ yarn add react-native-okaycam@3.x.x
Android
- Navigate to
androidfolder - Add following snippet in the root
build.gradlefile:
allprojects {
repositories {
maven {
url "https://innov8tif-okaycam.firebaseapp.com"
content {
includeGroup "com.innov8tif.xendity"
}
}
}
}
- Sync gradle
iOS
- Navigate to ios folder
- Add the following code to Podfile
platform :ios, '15.0'
use_frameworks!
post_install do |installer|
installer.pods_project.targets.each do |target|
if (target.name&.eql?('FBReactNativeSpec'))
target.build_phases.each do |build_phase|
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
target.build_phases.move(build_phase, 0)
end
end
end
target.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
if target.name == "CryptoSwift"
puts "Enable module stability for CryptoSwift"
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
if target.name == 'fmt'
puts "Enable module stability for fmt"
config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17'
end
end
end
end
Run command
pod installAdd camera permission
Android Issue
Duplicate class org.hamcrest.xxx
If you encouter the errors above, you may exclude junit module.
configurations { compile.exclude group: "junit", module: "junit" }
iOS Issue
Undefined symbol: _swift_FORCE_LOAD$_swiftUniformTypeIdentifiers
Undefined symbol: _swift_FORCE_LOAD$_swiftCoreMIDI
If you encouter the errors above, you may create a new swift file called Void.swift without adding bridging header.

License
Apply licenses for Android and iOS SDKs
const license = Platform.select({
android: "",
ios: ""
})
OkayCam Document
Configuration
| - | Property name | Description | Default value |
|---|---|---|---|
| width | width to resize the image | 2000 | |
| imageQuality | quality of cropped image | 1.0f | |
| New autoCapture | When set to true, the system will automatically capture the document once it is properly detected and aligned. When set to false, the user must manually trigger the capture instead. |
true | |
| New mode | FULL | Captures front of document, front of document with flash, and back of document automatically. This is the default mode for complete document capture. | |
| FRONT_ONLY | Captures only the front of document. | ||
| FRONT_BACK | Captures both front and back of document automatically without flash. | ||
| FRONT_WITH_FLASH | Captures the front of document with flash enabled |
Usage
import { captureDocument, DocumentCaptureMode } from "react-native-okaycam"
captureDocument(license, false, {
width: 2000,
imageQuality: 0.8,
mode: DocumentCaptureMode.FULL,
})
.then(result => {
console.log(JSON.stringify(result));
})
.catch(error => {
console.log(JSON.stringify(error));
});
Result
| Result | Description |
|---|---|
| fullDocumentImage | Result of first photo |
| fullDocumentImage2 | Result of first photo cropped |
| fullDocumentImage3 | Result of second photo |
| fullDocumentImage4 | Result of second photo cropped |
OkayCam Selfie
Configuration
| - | Property name | Description | Default value |
|---|---|---|---|
| width | width to resize the image | null | |
| - | imageQuality | quality of image | 1.0 (range from 0.0 to 1.0) |
| topLabel | text | text of the top label | Please align your face within the frame |
| topLabel | color | color of the top label | #FFFFFF |
| topLabel | size | text size of the top label | 24 |
| - | bottomFrameColor | color of the bottom frame | #EB6709 |
| switchBtnConfig | color | color of the switch button | #FFFFFF |
| switchBtnConfig | show | show or hide the camera switch button | true |
| confirmBtnConfig | backgroundColor | background color of the confirm button | #ffa500 |
| confirmBtnConfig | contentColor | content color of the confirm button | #ffffff |
| retakeBtnConfig | backgroundColor | background color of the retake button | #ffa500 |
| retakeBtnConfig | contentColor | content color of the retake button | #ffffff |
| - | captureBtnColor | color of the capture button | #FFFFFF |
| - | defaultCameraFacing | initial camera facing when the selfie cam is launched | CameraFacing.FRONT |
Usage
import { captureSelfie } from "react-native-okaycam"
captureSelfie(
license,
{
topLabel: {
text: "Align you face within the frame",
color: "#4287f5",
size: 20
},
bottomFrameColor: "#4287f5",
captureBtnColor: "#ffffff",
switchBtnConfig: {
color: "#ffffff",
show: true
},
confirmBtnConfig: {
backgroundColor: "#4287f5",
contentColor: "#000000"
},
retakeBtnConfig: {
backgroundColor: "#4287f5",
contentColor: "#000000"
},
defaultCameraFacing: "front",
width: 1000,
imageQuality: 1.0
}
)
.then(result => {
console.log(result)
})
.catch(error => {
console.log(error)
})
Result
| Result | Description |
|---|---|
| selfieImage | Captured selfie image |
Error Codes
| Error | Description |
|---|---|
| invalid license | The license is invalid |
| camera permission denied | The use did not grant the permission to access camera in order to do OCR |
| cancel | The user canceled during the scanning process |