capacitor-microblink 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Package.swift CHANGED
@@ -11,7 +11,8 @@ let package = Package(
11
11
  ],
12
12
  dependencies: [
13
13
  .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.1"),
14
- .package(url: "https://github.com/MicroblinkPlatform/microblink-platform-ios.git", from: "1.7.0")
14
+ .package(url: "https://github.com/BlinkCard/blinkcard-ios.git", .upToNextMajor(from: "3000.0.0"))
15
+
15
16
  ],
16
17
  targets: [
17
18
  .target(
@@ -19,8 +20,7 @@ let package = Package(
19
20
  dependencies: [
20
21
  .product(name: "Capacitor", package: "capacitor-swift-pm"),
21
22
  .product(name: "Cordova", package: "capacitor-swift-pm"),
22
- .product(name: "BlinkCard", package: "microblink-platform-ios"),
23
- .product(name: "MicroblinkPlatform", package: "microblink-platform-ios")
23
+ .product(name: "BlinkCardUX", package: "blinkcard-ios")
24
24
  ],
25
25
  path: "ios/Sources/MicroblinkPlugin"),
26
26
  .testTarget(
package/README.md CHANGED
@@ -9,37 +9,45 @@ npm install capacitor-microblink
9
9
  npx cap sync
10
10
  ```
11
11
 
12
+ ### Android Auto Init (on app startup)
13
+
14
+ If you want `initializeBlinkCard` to run automatically during Android plugin load (`onCreate` phase), set plugin config values:
15
+
16
+ ```ts
17
+ // capacitor.config.ts
18
+ plugins: {
19
+ Microblink: {
20
+ licenseKey: 'YOUR_BLINKCARD_LICENSE_KEY',
21
+ licensee: 'OPTIONAL_LICENSEE',
22
+ },
23
+ }
24
+ ```
25
+
26
+ ### iOS Camera Permission
27
+
28
+ BlinkCard scanning requires camera access on iOS.
29
+
30
+ Add this key to your app `Info.plist`:
31
+
32
+ ```xml
33
+ <key>NSCameraUsageDescription</key>
34
+ <string>We need camera access to scan your card.</string>
35
+ ```
36
+
12
37
  ## API
13
38
 
14
39
  <docgen-index>
15
40
 
16
- * [`startVerification(...)`](#startverification)
17
41
  * [`scanCard(...)`](#scancard)
42
+ * [`initializeBlinkCard(...)`](#initializeblinkcard)
43
+ * [`terminateBlinkCard()`](#terminateblinkcard)
18
44
  * [Interfaces](#interfaces)
19
- * [Type Aliases](#type-aliases)
20
45
 
21
46
  </docgen-index>
22
47
 
23
48
  <docgen-api>
24
49
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
25
50
 
26
- ### startVerification(...)
27
-
28
- ```typescript
29
- startVerification(options: StartVerificationOptions) => Promise<StartVerificationResult>
30
- ```
31
-
32
- Starts Microblink identity verification flow.
33
-
34
- | Param | Type |
35
- | ------------- | ----------------------------------------------------------------------------- |
36
- | **`options`** | <code><a href="#startverificationoptions">StartVerificationOptions</a></code> |
37
-
38
- **Returns:** <code>Promise&lt;<a href="#startverificationresult">StartVerificationResult</a>&gt;</code>
39
-
40
- --------------------
41
-
42
-
43
51
  ### scanCard(...)
44
52
 
45
53
  ```typescript
@@ -57,45 +65,37 @@ Starts BlinkCard card scanning flow.
57
65
  --------------------
58
66
 
59
67
 
60
- ### Interfaces
68
+ ### initializeBlinkCard(...)
61
69
 
70
+ ```typescript
71
+ initializeBlinkCard(options: InitializeBlinkCardOptions) => Promise<InitializeBlinkCardResult>
72
+ ```
62
73
 
63
- #### StartVerificationResult
74
+ Initializes BlinkCard SDK/license before scanning.
64
75
 
65
- | Prop | Type |
66
- | -------------------- | --------------------------------------------------------- |
67
- | **`canceled`** | <code>boolean</code> |
68
- | **`transactionId`** | <code>string \| null</code> |
69
- | **`status`** | <code>'accept' \| 'review' \| 'reject'</code> |
70
- | **`cancelReason`** | <code>'userCanceled' \| 'consentDenied'</code> |
71
- | **`cardScanResult`** | <code><a href="#cardscanresult">CardScanResult</a></code> |
76
+ | Param | Type |
77
+ | ------------- | --------------------------------------------------------------------------------- |
78
+ | **`options`** | <code><a href="#initializeblinkcardoptions">InitializeBlinkCardOptions</a></code> |
72
79
 
80
+ **Returns:** <code>Promise&lt;<a href="#initializeblinkcardresult">InitializeBlinkCardResult</a>&gt;</code>
73
81
 
74
- #### CardScanResult
82
+ --------------------
75
83
 
76
- | Prop | Type |
77
- | ---------------- | ------------------- |
78
- | **`cardNumber`** | <code>string</code> |
79
- | **`expiryDate`** | <code>string</code> |
80
- | **`owner`** | <code>string</code> |
81
- | **`cvv`** | <code>string</code> |
82
84
 
85
+ ### terminateBlinkCard()
86
+
87
+ ```typescript
88
+ terminateBlinkCard() => Promise<TerminateBlinkCardResult>
89
+ ```
90
+
91
+ Terminates BlinkCard SDK and clears cached plugin initialization state.
83
92
 
84
- #### StartVerificationOptions
93
+ **Returns:** <code>Promise&lt;<a href="#terminateblinkcardresult">TerminateBlinkCardResult</a>&gt;</code>
94
+
95
+ --------------------
85
96
 
86
- | Prop | Type |
87
- | -------------------------------- | --------------------------------------------------------------- |
88
- | **`workflowId`** | <code>string</code> |
89
- | **`url`** | <code>string</code> |
90
- | **`userId`** | <code>string</code> |
91
- | **`isProcessingStoringAllowed`** | <code>boolean</code> |
92
- | **`isTrainingAllowed`** | <code>boolean</code> |
93
- | **`note`** | <code>string</code> |
94
- | **`givenOn`** | <code>number</code> |
95
- | **`additionalRequestHeaders`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> |
96
- | **`startTransactionPath`** | <code>string</code> |
97
- | **`cancelWorkflowPath`** | <code>string</code> |
98
- | **`workflowInfoPath`** | <code>string</code> |
97
+
98
+ ### Interfaces
99
99
 
100
100
 
101
101
  #### ScanCardResult
@@ -137,13 +137,25 @@ Starts BlinkCard card scanning flow.
137
137
  | **`enableEditScreen`** | <code>boolean</code> |
138
138
 
139
139
 
140
- ### Type Aliases
140
+ #### InitializeBlinkCardResult
141
+
142
+ | Prop | Type |
143
+ | ----------------- | -------------------- |
144
+ | **`initialized`** | <code>boolean</code> |
141
145
 
142
146
 
143
- #### Record
147
+ #### InitializeBlinkCardOptions
148
+
149
+ | Prop | Type |
150
+ | ---------------- | ------------------- |
151
+ | **`licenseKey`** | <code>string</code> |
152
+ | **`licensee`** | <code>string</code> |
153
+
144
154
 
145
- Construct a type with a set of properties K of type T
155
+ #### TerminateBlinkCardResult
146
156
 
147
- <code>{
148
157
  [P in K]: T;
149
158
  }</code>
159
+ | Prop | Type |
160
+ | ---------------- | -------------------- |
161
+ | **`terminated`** | <code>boolean</code> |
150
162
 
151
163
  </docgen-api>
@@ -6,6 +6,9 @@ ext {
6
6
  }
7
7
 
8
8
  buildscript {
9
+ ext {
10
+ kotlin_version = '2.2.0'
11
+ }
9
12
  repositories {
10
13
  google()
11
14
  mavenCentral()
@@ -13,10 +16,14 @@ buildscript {
13
16
  }
14
17
  dependencies {
15
18
  classpath 'com.android.tools.build:gradle:8.13.0'
19
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16
20
  }
17
21
  }
18
22
 
19
23
  apply plugin: 'com.android.library'
24
+ apply plugin: 'org.jetbrains.kotlin.android'
25
+
26
+ def jvmTargetVersion = project.hasProperty('jvmTargetVersion') ? project.property('jvmTargetVersion') : '17'
20
27
 
21
28
  android {
22
29
  namespace = "com.otto.microblink"
@@ -40,8 +47,11 @@ android {
40
47
  disable += ["Aligned16KB"]
41
48
  }
42
49
  compileOptions {
43
- sourceCompatibility JavaVersion.VERSION_21
44
- targetCompatibility JavaVersion.VERSION_21
50
+ sourceCompatibility JavaVersion.toVersion(jvmTargetVersion)
51
+ targetCompatibility JavaVersion.toVersion(jvmTargetVersion)
52
+ }
53
+ kotlinOptions {
54
+ jvmTarget = jvmTargetVersion
45
55
  }
46
56
  }
47
57
 
@@ -56,8 +66,8 @@ dependencies {
56
66
  implementation fileTree(dir: 'libs', include: ['*.jar'])
57
67
  implementation project(':capacitor-android')
58
68
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
59
- implementation "com.microblink:blinkcard:2.12.0"
60
- implementation "com.microblink:microblink-platform:1.7.0"
69
+ implementation("com.microblink:blinkcard-ux:3000.0.0")
70
+ implementation 'androidx.core:core-ktx:1.17.0'
61
71
  testImplementation "junit:junit:$junitVersion"
62
72
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
63
73
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
@@ -0,0 +1,63 @@
1
+ package com.otto.microblink
2
+
3
+ import android.content.Context
4
+ import com.microblink.blinkcard.core.BlinkCardSdk
5
+ import com.microblink.blinkcard.core.BlinkCardSdkSettings
6
+ import kotlinx.coroutines.CoroutineScope
7
+ import kotlinx.coroutines.Dispatchers
8
+ import kotlinx.coroutines.launch
9
+
10
+ object BlinkCardInitBridge {
11
+ private fun resetSdkInstance() {
12
+ try {
13
+ val sdkField = BlinkCardSdk::class.java.getDeclaredField("sdkInstance")
14
+ sdkField.isAccessible = true
15
+ val existingSdk = sdkField.get(null) as? BlinkCardSdk
16
+ existingSdk?.close()
17
+ sdkField.set(null, null)
18
+ } catch (_: Throwable) {
19
+ // Best-effort reset. If reflection fails, initialization may still succeed.
20
+ }
21
+ }
22
+
23
+ @JvmStatic
24
+ fun initialize(
25
+ context: Context,
26
+ licenseKey: String,
27
+ licensee: String?,
28
+ callback: (Throwable?) -> Unit
29
+ ) {
30
+ CoroutineScope(Dispatchers.Main).launch {
31
+ resetSdkInstance()
32
+ val normalizedLicenseKey = licenseKey.trim()
33
+ val normalizedLicensee = licensee?.trim()?.takeIf { it.isNotEmpty() }
34
+ val settings = if (normalizedLicensee != null) {
35
+ BlinkCardSdkSettings(
36
+ licenseKey = normalizedLicenseKey,
37
+ licensee = normalizedLicensee
38
+ )
39
+ } else {
40
+ BlinkCardSdkSettings(
41
+ licenseKey = normalizedLicenseKey
42
+ )
43
+ }
44
+ val result = BlinkCardSdk.initializeSdk(
45
+ context.applicationContext,
46
+ settings
47
+ )
48
+ callback(result.exceptionOrNull())
49
+ }
50
+ }
51
+
52
+ @JvmStatic
53
+ fun terminate(callback: (Throwable?) -> Unit) {
54
+ CoroutineScope(Dispatchers.Main).launch {
55
+ try {
56
+ resetSdkInstance()
57
+ callback(null)
58
+ } catch (error: Throwable) {
59
+ callback(error)
60
+ }
61
+ }
62
+ }
63
+ }