@qore-id/react-native-qoreid-sdk 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -17,44 +17,37 @@ yarn add @qore-id/react-native-qoreid-sdk
17
17
  Add the following to your `app/build.gradle`
18
18
 
19
19
  ```groovy
20
- //before your dependencies
21
- repositories {
22
- mavenCentral()
23
- google()
24
- maven {
25
- url "https://repo.qoreid.com/repository/maven-releases/"
26
- }
27
- }
28
-
20
+ repositories {
21
+ mavenCentral()
22
+ google()
23
+ maven {
24
+ url "https://repo.qoreid.com/repository/maven-releases/"
25
+ }
26
+ }
29
27
  ```
30
28
 
31
- In your `android/app/res/values/styles.xml` Add the Material Component theme to use the QoreIdButton.
32
-
33
- ```xml
34
- <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar" />
35
- ```
29
+ Add this snippet of code to your `~/java/com.<app name>/MainActivity`
30
+ ```java
31
+ @Override
32
+ protected void onCreate(Bundle savedInstanceState) {
33
+ super.onCreate(savedInstanceState);
34
+ QoreidSdkModule.initialize(this);
35
+ }
36
36
 
37
- Add the material library to your `app/build.gradle` dependency
38
-
39
- ```groovy
40
- dependencies {
41
- ...
42
- implementation 'com.google.android.material:material:1.7.0'
43
- ...
44
- }
45
37
  ```
46
38
 
47
- ### iOS
39
+ <!-- ### iOS
48
40
 
49
41
  From your root directory
50
42
 
51
43
  ```sh
52
- cd ios && pod install
53
- ```
44
+ npm i react-native-webview
45
+ ``` -->
46
+
54
47
 
55
- ## Usage
48
+ ## Usage
56
49
 
57
- ```coffeescript verify.tsx
50
+ ```tsx
58
51
  //verify.tsx
59
52
  import React from 'react'
60
53
  import { QoreIdButton } from '@qore-id/react-native-qoreid-sdk';
@@ -62,7 +55,7 @@ import { QoreIdButton } from '@qore-id/react-native-qoreid-sdk';
62
55
 
63
56
  function App() {
64
57
 
65
- let clientId = /* CLIENT ID */
58
+ const customButton = ({ onPress }) => <Button onPress={onPress} title="QoreId Button" />
66
59
 
67
60
  const onError = (data) => {
68
61
  console.error(data);
@@ -84,10 +77,10 @@ function App() {
84
77
  {/* Other components */}
85
78
  <QoreIdButton
86
79
  title="Verify"
87
- flowId="" {/* defaults to 0 */}
88
- clientId={clientId} {/* Required */}
80
+ flowId=""
81
+ clientId="" {/* Required */}
89
82
  productCode="" {/* Required */}
90
- customerReference={customerRef} {/* Required */}
83
+ customerReference="" {/* Required */}
91
84
  applicantData={{
92
85
  firstName:"",
93
86
  middleName:"",
@@ -106,6 +99,7 @@ function App() {
106
99
  onQoreIDSdkSubmitted={onSumitted}
107
100
  onQoreIDSdkError={onError}
108
101
  onQoreIDSdkClosed={onClosed}
102
+ render={customButton}
109
103
  />
110
104
  </View>
111
105
  )
@@ -113,7 +107,11 @@ function App() {
113
107
 
114
108
  ```
115
109
 
116
- ## Utilities
110
+
111
+
112
+
113
+
114
+ ### Utilities
117
115
 
118
116
  QoreId SDK exposes utilities that you can easily use
119
117
 
@@ -49,6 +49,7 @@ android {
49
49
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
50
50
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
51
51
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
52
+ buildConfigField "String", "s", "\"react_native_android_sdk\""
52
53
  multiDexEnabled true
53
54
  }
54
55
  buildTypes {
@@ -91,8 +92,7 @@ dependencies {
91
92
  // For < 0.71, this will be from the local maven repo
92
93
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
93
94
  //noinspection GradleDynamicVersion
94
- implementation 'com.qoreid:qoreid-sdk:1.0.1'
95
- implementation 'com.google.android.material:material:1.7.0'
95
+ implementation 'com.qoreid:qoreid-sdk:1.1.0'
96
96
  implementation "com.google.code.gson:gson:2.8.5"
97
97
  implementation "com.facebook.react:react-native:+"
98
98
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
@@ -1,88 +1,156 @@
1
1
  package com.qoreidsdk
2
2
 
3
3
 
4
-
5
4
  import android.app.Activity
6
5
  import android.content.Intent
7
6
  import android.os.Build
7
+ import android.util.Log
8
8
  import com.facebook.react.bridge.*
9
9
  import com.facebook.react.modules.core.DeviceEventManagerModule
10
- import com.qoreid.sdk.core.QoreIdSdkKt.QORE_ID_RESULT_CODE
11
- import com.qoreid.sdk.core.QoreIdSdkKt.QORE_ID_RESULT_EXTRA_KEY
10
+ import com.google.gson.Gson
11
+ import com.qoreid.sdk.core.QoreIDParams
12
+ import com.qoreid.sdk.core.QoreIDSdk
13
+ import com.qoreid.sdk.core.QoreIDSdk.QORE_ID_RESULT_CODE
14
+ import com.qoreid.sdk.core.QoreIDSdk.QORE_ID_RESULT_EXTRA_KEY
15
+ import com.qoreid.sdk.core.models.AddressData
16
+ import com.qoreid.sdk.core.models.ApplicantData
12
17
  import com.qoreid.sdk.core.models.ErrorResult
13
18
  import com.qoreid.sdk.core.models.QoreIDResult
14
19
  import com.qoreid.sdk.core.models.SuccessResult
15
20
 
16
21
 
22
+
23
+
17
24
  class QoreidSdkModule(val reactContext: ReactApplicationContext) :
18
- ReactContextBaseJavaModule(reactContext) {
19
-
20
- private var qoreIdResult: QoreIDResult? = null;
21
-
22
- private val activityEventListener =
23
- object : BaseActivityEventListener() {
24
- override fun onActivityResult(
25
- activity: Activity?,
26
- requestCode: Int,
27
- resultCode: Int,
28
- intent: Intent?
29
- ) {
30
-
31
- if (resultCode == QORE_ID_RESULT_CODE && intent != null) {
32
- qoreIdResult = if (Build.VERSION.SDK_INT < 33) {
33
- intent.extras?.getSerializable(QORE_ID_RESULT_EXTRA_KEY) as QoreIDResult
34
- } else {
35
- intent.extras?.getSerializable(QORE_ID_RESULT_EXTRA_KEY, QoreIDResult::class.java)
36
- }
37
-
38
- processQoreIDResult(reactContext, qoreIdResult!!)
25
+ ReactContextBaseJavaModule(reactContext){
26
+ private var qoreIdResult: QoreIDResult? = null;
27
+
28
+
29
+ private val activityEventListener =
30
+ object : BaseActivityEventListener() {
31
+ override fun onActivityResult(
32
+ activity: Activity?,
33
+ requestCode: Int,
34
+ resultCode: Int,
35
+ intent: Intent?
36
+ ) {
37
+
38
+ if (resultCode == QORE_ID_RESULT_CODE && intent != null) {
39
+ qoreIdResult = if (Build.VERSION.SDK_INT < 33) {
40
+ intent.extras?.getSerializable(QORE_ID_RESULT_EXTRA_KEY) as QoreIDResult
41
+ } else {
42
+ intent.extras?.getSerializable(
43
+ QORE_ID_RESULT_EXTRA_KEY,
44
+ QoreIDResult::class.java
45
+ )
46
+ }
47
+ processQoreIDResult(reactContext, qoreIdResult!!)
48
+ }
49
+ }
50
+
39
51
  }
40
- }
52
+
53
+
54
+ init {
55
+ reactContext.addActivityEventListener(activityEventListener)
56
+ }
57
+
58
+ override fun getName(): String {
59
+ return NAME
41
60
  }
42
61
 
43
- init {
44
- reactContext.addActivityEventListener(activityEventListener)
45
- }
46
62
 
47
- override fun getName(): String {
48
- return NAME
49
- }
63
+ @ReactMethod
64
+ fun launchQoreId(jsonData: String) {
50
65
 
66
+ if (currentActivity == null) {
67
+ Log.e("Error", "No current activity");
68
+ return
69
+ }
51
70
 
52
- fun processQoreIDResult(context: ReactContext, qoreIdResult: QoreIDResult) {
53
- when (qoreIdResult) {
54
- is ErrorResult -> {
55
- // Handle error.
56
- val event = Arguments.createMap().apply {
57
- putString("code", qoreIdResult.code.toString())
58
- putString("data", qoreIdResult.data.toString())
59
- putString("message", qoreIdResult.message)
71
+ val gson = Gson()
72
+ val qoreIdJSData = gson.fromJson(jsonData, QoreIdJSData::class.java)
73
+
74
+ val config = qoreIdJSData.config
75
+ val apD = qoreIdJSData.applicantData
76
+ val applicantData = ApplicantData(
77
+ apD.firstName,
78
+ apD.lastName,
79
+ apD.phoneNumber,
80
+ apD.middleName,
81
+ apD.dob,
82
+ apD.dob,
83
+ apD.gender
84
+ )
85
+
86
+ val adD = qoreIdJSData.addressData
87
+ val addressData = AddressData(
88
+ adD.address,
89
+ adD.city,
90
+ adD.lga,
91
+ adD.state,
92
+ )
93
+
94
+ val qoreIDParams = if (config.flowId != 0L) {
95
+ QoreIDParams()
96
+ .clientId(config.clientId)
97
+ .customerReference(qoreIdJSData.config.customerRef)
98
+ .inputData(applicantData, addressData)
99
+ .ocrAcceptedDocuments(qoreIdJSData.acceptedDocuments)
100
+ .workflow(config.flowId!!)
101
+
102
+ } else {
103
+ QoreIDParams()
104
+ .clientId(config.clientId)
105
+ .customerReference(qoreIdJSData.config.customerRef)
106
+ .inputData(applicantData, addressData)
107
+ .ocrAcceptedDocuments(qoreIdJSData.acceptedDocuments)
108
+ .collection(config.productCode)
60
109
  }
61
110
 
62
- sendEvent(context, "onResult", event)
111
+ QoreIDSdk.s(BuildConfig.s);
112
+ QoreIDSdk.params(qoreIDParams)
113
+ QoreIDSdk.launch(requireNotNull(currentActivity))
114
+ }
63
115
 
64
- }
65
- is SuccessResult -> {
66
- // Handle success.
67
- val event = Arguments.createMap().apply {
68
- putString("data", qoreIdResult.data.toString())
69
- putString("message", qoreIdResult.message)
116
+ fun processQoreIDResult(context: ReactContext, qoreIdResult: QoreIDResult) {
117
+ when (qoreIdResult) {
118
+ is ErrorResult -> {
119
+ // Handle error.
120
+ val event = Arguments.createMap().apply {
121
+ putString("code", qoreIdResult.code.toString())
122
+ putString("data", qoreIdResult.data.toString())
123
+ putString("message", qoreIdResult.message)
124
+ }
125
+
126
+ sendEvent(context, "onResult", event)
127
+
128
+ }
129
+ is SuccessResult -> {
130
+ // Handle success.
131
+ val event = Arguments.createMap().apply {
132
+ putString("data", qoreIdResult.data.toString())
133
+ putString("message", qoreIdResult.message)
134
+ }
135
+
136
+ sendEvent(context, "onResult", event)
137
+ }
70
138
  }
71
-
72
- sendEvent(context, "onResult", event)
73
- }
74
139
  }
75
- }
76
140
 
77
141
 
78
- private fun sendEvent(reactContext: ReactContext, eventName: String, params: WritableMap?) {
79
- reactContext
80
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
81
- .emit(eventName, params)
82
- }
142
+ private fun sendEvent(reactContext: ReactContext, eventName: String, params: WritableMap?) {
143
+ reactContext
144
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
145
+ .emit(eventName, params)
146
+ }
83
147
 
84
- companion object {
85
- const val NAME = "QoreidSdk"
86
- }
148
+ companion object {
149
+ const val NAME = "QoreidSdk"
87
150
 
151
+ @JvmStatic
152
+ fun initialize(activity: Activity) {
153
+ QoreIDSdk.initialize(activity);
154
+ }
155
+ }
88
156
  }
@@ -14,7 +14,7 @@ class QoreidSdkPackage : ReactPackage {
14
14
  }
15
15
 
16
16
  override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
17
- return listOf(QoreIdReactButtonManager(reactContext))
17
+ return listOf()
18
18
  }
19
19
 
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","QoreIdButton","Platform","OS"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AANO,MAAMS,YAAY,GACvBC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACpBhB,OAAO,CAAC,wBAAwB,CAAC,CAC/Bc,YAAY,GACf,CAAC,CAA4B,EAAC;AAAAJ,OAAA,CAAAI,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["_reactNative","require","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","QoreIdButton","Platform","OS"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AANO,MAAMS,YAAY,GACvBC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACpBhB,OAAO,CAAC,wBAAwB,CAAC,CAC/Bc,YAAY,GACd,CAAC,CAA6B,CAAC,CAAC;AAAAJ,OAAA,CAAAI,YAAA,GAAAA,YAAA"}
@@ -8,31 +8,9 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
10
10
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
11
- const QoreIdReactButtonManager = (0, _reactNative.requireNativeComponent)('QoreIdReactButtonManager');
12
- const Button = /*#__PURE__*/(0, _react.forwardRef)((_props, ref) => {
13
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
14
- style: {
15
- position: 'relative',
16
- margin: 'auto',
17
- height: 55,
18
- borderWidth: 1
19
- }
20
- }, /*#__PURE__*/_react.default.createElement(QoreIdReactButtonManager
21
- //@ts-ignore
22
- , {
23
- ref: ref
24
- })));
25
- });
26
- function useQoreId(ref, options) {
27
- const onSubmitted = (0, _react.useCallback)(data => options.onSubmitted && options.onSubmitted(data), [options]);
28
- const onError = (0, _react.useCallback)(data => options.onError && options.onError(data), [options]);
29
- (0, _react.useEffect)(() => {
30
- var _UIManager$QoreIdReac, _UIManager$QoreIdReac2;
31
- const buttonStyles = JSON.stringify(options.buttonProps);
32
- _reactNative.UIManager.dispatchViewManagerCommand((0, _reactNative.findNodeHandle)(ref.current), // we are calling the 'create' command
33
- //@ts-ignore
34
- _reactNative.UIManager === null || _reactNative.UIManager === void 0 ? void 0 : (_UIManager$QoreIdReac = _reactNative.UIManager.QoreIdReactButtonManager) === null || _UIManager$QoreIdReac === void 0 ? void 0 : (_UIManager$QoreIdReac2 = _UIManager$QoreIdReac.Commands) === null || _UIManager$QoreIdReac2 === void 0 ? void 0 : _UIManager$QoreIdReac2.create.toString(), [(0, _reactNative.findNodeHandle)(ref.current), options.config, buttonStyles]);
35
- }, []);
11
+ const QoreIdButton = initialData => {
12
+ const onSubmitted = (0, _react.useCallback)(data => initialData.onQoreIDSdkSubmitted && initialData.onQoreIDSdkSubmitted(data), [initialData]);
13
+ const onError = (0, _react.useCallback)(data => initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data), [initialData]);
36
14
  (0, _react.useEffect)(() => {
37
15
  const eventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.QoreidSdk);
38
16
  let eventListener = eventEmitter.addListener('onResult', event => {
@@ -46,57 +24,32 @@ function useQoreId(ref, options) {
46
24
  eventListener.remove();
47
25
  };
48
26
  }, []);
49
- }
50
- const onChangeData = (ref, data) => {
51
- const stringified = JSON.stringify(data);
52
- return (0, _react.useEffect)(() => {
53
- var _UIManager$QoreIdReac3, _UIManager$QoreIdReac4;
54
- _reactNative.UIManager.dispatchViewManagerCommand((0, _reactNative.findNodeHandle)(ref.current), // we are calling the 'create' command
55
- //@ts-ignore
56
- _reactNative.UIManager === null || _reactNative.UIManager === void 0 ? void 0 : (_UIManager$QoreIdReac3 = _reactNative.UIManager.QoreIdReactButtonManager) === null || _UIManager$QoreIdReac3 === void 0 ? void 0 : (_UIManager$QoreIdReac4 = _UIManager$QoreIdReac3.Commands) === null || _UIManager$QoreIdReac4 === void 0 ? void 0 : _UIManager$QoreIdReac4.update.toString(), [stringified]);
57
- }, [stringified]);
58
- };
59
- const QoreIdButton = initialData => {
60
- var _initialData$ocrAccep, _initialData$ocrAccep2;
61
- const ref = (0, _react.useRef)(null);
62
- useQoreId(ref, {
63
- config: JSON.stringify({
64
- flowId: initialData.flowId || 0,
65
- customerRef: initialData.customerReference,
66
- productCode: initialData.productCode,
67
- clientId: initialData.clientId,
68
- acceptedDocuments: (_initialData$ocrAccep = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep === void 0 ? void 0 : _initialData$ocrAccep.split(',')
69
- }),
70
- onError(data) {
71
- initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data);
72
- },
73
- onSubmitted(data) {
74
- initialData.onQoreIDSdkSubmitted && initialData.onQoreIDSdkSubmitted(data);
75
- },
76
- buttonProps: {
77
- title: initialData.title
78
- }
79
- });
80
- onChangeData(ref, {
81
- config: {
82
- flowId: initialData.flowId || 0,
83
- customerRef: initialData.customerReference,
84
- productCode: initialData.productCode,
85
- clientId: initialData.clientId
86
- },
87
- applicantData: {
88
- ...initialData.applicantData
89
- },
90
- addressData: {
91
- ...initialData.addressData
92
- },
93
- acceptedDocuments: (_initialData$ocrAccep2 = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep2 === void 0 ? void 0 : _initialData$ocrAccep2.split(','),
94
- identityData: {
95
- ...initialData.identityData
96
- }
97
- });
98
- return /*#__PURE__*/_react.default.createElement(Button, {
99
- ref: ref
27
+ const startDSK = () => {
28
+ var _initialData$ocrAccep;
29
+ _reactNative.NativeModules.QoreidSdk.launchQoreId(JSON.stringify({
30
+ config: {
31
+ flowId: initialData.flowId || 0,
32
+ customerRef: initialData.customerReference,
33
+ productCode: initialData.productCode,
34
+ clientId: initialData.clientId
35
+ },
36
+ applicantData: {
37
+ ...initialData.applicantData
38
+ },
39
+ addressData: {
40
+ ...initialData.addressData
41
+ },
42
+ acceptedDocuments: (_initialData$ocrAccep = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep === void 0 ? void 0 : _initialData$ocrAccep.split(','),
43
+ identityData: {
44
+ ...initialData.identityData
45
+ }
46
+ }));
47
+ };
48
+ return initialData.render ? initialData.render({
49
+ onPress: startDSK
50
+ }) : /*#__PURE__*/_react.default.createElement(_reactNative.Button, {
51
+ onPress: startDSK,
52
+ title: "Start Verification"
100
53
  });
101
54
  };
102
55
  exports.QoreIdButton = QoreIdButton;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","QoreIdReactButtonManager","requireNativeComponent","Button","forwardRef","_props","ref","createElement","Fragment","View","style","position","margin","height","borderWidth","useQoreId","options","onSubmitted","useCallback","data","onError","useEffect","_UIManager$QoreIdReac","_UIManager$QoreIdReac2","buttonStyles","JSON","stringify","buttonProps","UIManager","dispatchViewManagerCommand","findNodeHandle","current","Commands","create","toString","config","eventEmitter","NativeEventEmitter","NativeModules","QoreidSdk","eventListener","addListener","event","code","remove","onChangeData","stringified","_UIManager$QoreIdReac3","_UIManager$QoreIdReac4","update","QoreIdButton","initialData","_initialData$ocrAccep","_initialData$ocrAccep2","useRef","flowId","customerRef","customerReference","productCode","clientId","acceptedDocuments","ocrAcceptedDocuments","split","onQoreIDSdkError","onQoreIDSdkSubmitted","title","applicantData","addressData","identityData","exports"],"sourceRoot":"../../src","sources":["qoreIdButton.android.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AAOsB,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAA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Z,WAAW,CAACY,gBAAgB,CAAC5C,IAAI,CAAC;IACpE,CAAC;IACDF,WAAWA,CAACE,IAAI,EAAE;MAChBgC,WAAW,CAACa,oBAAoB,IAC9Bb,WAAW,CAACa,oBAAoB,CAAC7C,IAAI,CAAC;IAC1C,CAAC;IACDQ,WAAW,EAAE;MACXsC,KAAK,EAAEd,WAAW,CAACc;IACrB;EACF,CAAC,CAAC;EAEFpB,YAAY,CAACvC,GAAG,EAAE;IAChB6B,MAAM,EAAE;MACNoB,MAAM,EAAEJ,WAAW,CAACI,MAAM,IAAI,CAAC;MAC/BC,WAAW,EAAEL,WAAW,CAACM,iBAAiB;MAC1CC,WAAW,EAAEP,WAAW,CAACO,WAAY;MACrCC,QAAQ,EAAER,WAAW,CAACQ;IACxB,CAAC;IACDO,aAAa,EAAE;MACb,GAAGf,WAAW,CAACe;IACjB,CAAC;IACDC,WAAW,EAAE;MACX,GAAGhB,WAAW,CAACgB;IACjB,CAAC;IACDP,iBAAiB,GAAAP,sBAAA,GAAEF,WAAW,CAACU,oBAAoB,cAAAR,sBAAA,uBAAhCA,sBAAA,CAAkCS,KAAK,CAAC,GAAG,CAAC;IAC/DM,YAAY,EAAE;MAAE,GAAGjB,WAAW,CAACiB;IAAa;EAC9C,CAAC,CAAC;EACF,oBAAO7F,MAAA,CAAAW,OAAA,CAAAqB,aAAA,CAACJ,MAAM;IAACG,GAAG,EAAEA;EAAI,EAAG;AAC7B,CAAC;AAAC+D,OAAA,CAAAnB,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","QoreIdButton","initialData","onSubmitted","useCallback","data","onQoreIDSdkSubmitted","onError","onQoreIDSdkError","useEffect","eventEmitter","NativeEventEmitter","NativeModules","QoreidSdk","eventListener","addListener","event","code","remove","startDSK","_initialData$ocrAccep","launchQoreId","JSON","stringify","config","flowId","customerRef","customerReference","productCode","clientId","applicantData","addressData","acceptedDocuments","ocrAcceptedDocuments","split","identityData","render","onPress","createElement","Button","title","exports"],"sourceRoot":"../../src","sources":["qoreIdButton.android.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAyE,SAAAE,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAJ,wBAAAQ,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CA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0B,WAAY;QACrCC,QAAQ,EAAE3B,WAAW,CAAC2B;MACxB,CAAC;MACDC,aAAa,EAAE;QACb,GAAG5B,WAAW,CAAC4B;MACjB,CAAC;MACDC,WAAW,EAAE;QACX,GAAG7B,WAAW,CAAC6B;MACjB,CAAC;MACDC,iBAAiB,GAAAZ,qBAAA,GAAElB,WAAW,CAAC+B,oBAAoB,cAAAb,qBAAA,uBAAhCA,qBAAA,CAAkCc,KAAK,CAAC,GAAG,CAAC;MAC/DC,YAAY,EAAE;QAAE,GAAGjC,WAAW,CAACiC;MAAa;IAC9C,CAAC,CAAC,CACH;EACH,CAAC;EAED,OAAOjC,WAAW,CAACkC,MAAM,GACvBlC,WAAW,CAACkC,MAAM,CAAC;IAAEC,OAAO,EAAElB;EAAS,CAAC,CAAC,gBAEzC5C,MAAA,CAAAW,OAAA,CAAAoD,aAAA,CAAC5D,YAAA,CAAA6D,MAAM;IAACF,OAAO,EAAElB,QAAS;IAACqB,KAAK,EAAC;EAAoB,EACtD;AACH,CAAC;AAACC,OAAA,CAAAxC,YAAA,GAAAA,YAAA"}
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","QoreIdButton","OS","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAGvC,OAAO,MAAMC,YAAY,GACvBD,QAAQ,CAACE,EAAE,KAAK,SAAS,GACpBC,OAAO,CAAC,wBAAwB,CAAC,CAC/BF,YAAY,GACf,CAAC,CAA4B,EAAC;;AAEpC,cAAc,SAAS"}
1
+ {"version":3,"names":["Platform","QoreIdButton","OS","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAGvC,OAAO,MAAMC,YAAY,GACvBD,QAAQ,CAACE,EAAE,KAAK,SAAS,GACpBC,OAAO,CAAC,wBAAwB,CAAC,CAC/BF,YAAY,GACd,CAAC,CAA6B,CAAC,CAAC;;AAEvC,cAAc,SAAS"}
@@ -1,30 +1,8 @@
1
- import React, { forwardRef, useCallback, useEffect, useRef } from 'react';
2
- import { UIManager, findNodeHandle, requireNativeComponent, View, NativeEventEmitter, NativeModules } from 'react-native';
3
- const QoreIdReactButtonManager = requireNativeComponent('QoreIdReactButtonManager');
4
- const Button = /*#__PURE__*/forwardRef((_props, ref) => {
5
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
6
- style: {
7
- position: 'relative',
8
- margin: 'auto',
9
- height: 55,
10
- borderWidth: 1
11
- }
12
- }, /*#__PURE__*/React.createElement(QoreIdReactButtonManager
13
- //@ts-ignore
14
- , {
15
- ref: ref
16
- })));
17
- });
18
- function useQoreId(ref, options) {
19
- const onSubmitted = useCallback(data => options.onSubmitted && options.onSubmitted(data), [options]);
20
- const onError = useCallback(data => options.onError && options.onError(data), [options]);
21
- useEffect(() => {
22
- var _UIManager$QoreIdReac, _UIManager$QoreIdReac2;
23
- const buttonStyles = JSON.stringify(options.buttonProps);
24
- UIManager.dispatchViewManagerCommand(findNodeHandle(ref.current), // we are calling the 'create' command
25
- //@ts-ignore
26
- UIManager === null || UIManager === void 0 ? void 0 : (_UIManager$QoreIdReac = UIManager.QoreIdReactButtonManager) === null || _UIManager$QoreIdReac === void 0 ? void 0 : (_UIManager$QoreIdReac2 = _UIManager$QoreIdReac.Commands) === null || _UIManager$QoreIdReac2 === void 0 ? void 0 : _UIManager$QoreIdReac2.create.toString(), [findNodeHandle(ref.current), options.config, buttonStyles]);
27
- }, []);
1
+ import React, { useCallback, useEffect } from 'react';
2
+ import { NativeEventEmitter, NativeModules, Button } from 'react-native';
3
+ export const QoreIdButton = initialData => {
4
+ const onSubmitted = useCallback(data => initialData.onQoreIDSdkSubmitted && initialData.onQoreIDSdkSubmitted(data), [initialData]);
5
+ const onError = useCallback(data => initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data), [initialData]);
28
6
  useEffect(() => {
29
7
  const eventEmitter = new NativeEventEmitter(NativeModules.QoreidSdk);
30
8
  let eventListener = eventEmitter.addListener('onResult', event => {
@@ -38,57 +16,32 @@ function useQoreId(ref, options) {
38
16
  eventListener.remove();
39
17
  };
40
18
  }, []);
41
- }
42
- const onChangeData = (ref, data) => {
43
- const stringified = JSON.stringify(data);
44
- return useEffect(() => {
45
- var _UIManager$QoreIdReac3, _UIManager$QoreIdReac4;
46
- UIManager.dispatchViewManagerCommand(findNodeHandle(ref.current), // we are calling the 'create' command
47
- //@ts-ignore
48
- UIManager === null || UIManager === void 0 ? void 0 : (_UIManager$QoreIdReac3 = UIManager.QoreIdReactButtonManager) === null || _UIManager$QoreIdReac3 === void 0 ? void 0 : (_UIManager$QoreIdReac4 = _UIManager$QoreIdReac3.Commands) === null || _UIManager$QoreIdReac4 === void 0 ? void 0 : _UIManager$QoreIdReac4.update.toString(), [stringified]);
49
- }, [stringified]);
50
- };
51
- export const QoreIdButton = initialData => {
52
- var _initialData$ocrAccep, _initialData$ocrAccep2;
53
- const ref = useRef(null);
54
- useQoreId(ref, {
55
- config: JSON.stringify({
56
- flowId: initialData.flowId || 0,
57
- customerRef: initialData.customerReference,
58
- productCode: initialData.productCode,
59
- clientId: initialData.clientId,
60
- acceptedDocuments: (_initialData$ocrAccep = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep === void 0 ? void 0 : _initialData$ocrAccep.split(',')
61
- }),
62
- onError(data) {
63
- initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data);
64
- },
65
- onSubmitted(data) {
66
- initialData.onQoreIDSdkSubmitted && initialData.onQoreIDSdkSubmitted(data);
67
- },
68
- buttonProps: {
69
- title: initialData.title
70
- }
71
- });
72
- onChangeData(ref, {
73
- config: {
74
- flowId: initialData.flowId || 0,
75
- customerRef: initialData.customerReference,
76
- productCode: initialData.productCode,
77
- clientId: initialData.clientId
78
- },
79
- applicantData: {
80
- ...initialData.applicantData
81
- },
82
- addressData: {
83
- ...initialData.addressData
84
- },
85
- acceptedDocuments: (_initialData$ocrAccep2 = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep2 === void 0 ? void 0 : _initialData$ocrAccep2.split(','),
86
- identityData: {
87
- ...initialData.identityData
88
- }
89
- });
90
- return /*#__PURE__*/React.createElement(Button, {
91
- ref: ref
19
+ const startDSK = () => {
20
+ var _initialData$ocrAccep;
21
+ NativeModules.QoreidSdk.launchQoreId(JSON.stringify({
22
+ config: {
23
+ flowId: initialData.flowId || 0,
24
+ customerRef: initialData.customerReference,
25
+ productCode: initialData.productCode,
26
+ clientId: initialData.clientId
27
+ },
28
+ applicantData: {
29
+ ...initialData.applicantData
30
+ },
31
+ addressData: {
32
+ ...initialData.addressData
33
+ },
34
+ acceptedDocuments: (_initialData$ocrAccep = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep === void 0 ? void 0 : _initialData$ocrAccep.split(','),
35
+ identityData: {
36
+ ...initialData.identityData
37
+ }
38
+ }));
39
+ };
40
+ return initialData.render ? initialData.render({
41
+ onPress: startDSK
42
+ }) : /*#__PURE__*/React.createElement(Button, {
43
+ onPress: startDSK,
44
+ title: "Start Verification"
92
45
  });
93
46
  };
94
47
  //# sourceMappingURL=qoreIdButton.android.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","forwardRef","useCallback","useEffect","useRef","UIManager","findNodeHandle","requireNativeComponent","View","NativeEventEmitter","NativeModules","QoreIdReactButtonManager","Button","_props","ref","createElement","Fragment","style","position","margin","height","borderWidth","useQoreId","options","onSubmitted","data","onError","_UIManager$QoreIdReac","_UIManager$QoreIdReac2","buttonStyles","JSON","stringify","buttonProps","dispatchViewManagerCommand","current","Commands","create","toString","config","eventEmitter","QoreidSdk","eventListener","addListener","event","code","remove","onChangeData","stringified","_UIManager$QoreIdReac3","_UIManager$QoreIdReac4","update","QoreIdButton","initialData","_initialData$ocrAccep","_initialData$ocrAccep2","flowId","customerRef","customerReference","productCode","clientId","acceptedDocuments","ocrAcceptedDocuments","split","onQoreIDSdkError","onQoreIDSdkSubmitted","title","applicantData","addressData","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AAGd,WAAW,CAACc;IACjB,CAAC;IACDC,WAAW,EAAE;MACX,GAAGf,WAAW,CAACe;IACjB,CAAC;IACDP,iBAAiB,GAAAN,sBAAA,GAAEF,WAAW,CAACS,oBAAoB,cAAAP,sBAAA,uBAAhCA,sBAAA,CAAkCQ,KAAK,CAAC,GAAG,CAAC;IAC/DM,YAAY,EAAE;MAAE,GAAGhB,WAAW,CAACgB;IAAa;EAC9C,CAAC,CAAC;EACF,oBAAOpE,KAAA,CAAAe,aAAA,CAACH,MAAM;IAACE,GAAG,EAAEA;EAAI,EAAG;AAC7B,CAAC"}
1
+ {"version":3,"names":["React","useCallback","useEffect","NativeEventEmitter","NativeModules","Button","QoreIdButton","initialData","onSubmitted","data","onQoreIDSdkSubmitted","onError","onQoreIDSdkError","eventEmitter","QoreidSdk","eventListener","addListener","event","code","remove","startDSK","_initialData$ocrAccep","launchQoreId","JSON","stringify","config","flowId","customerRef","customerReference","productCode","clientId","applicantData","addressData","acceptedDocuments","ocrAcceptedDocuments","split","identityData","render","onPress","createElement","title"],"sourceRoot":"../../src","sources":["qoreIdButton.android.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,QAAQ,OAAO;AACrD,SAASC,kBAAkB,EAAEC,aAAa,EAAEC,MAAM,QAAQ,cAAc;AAGxE,OAAO,MAAMC,YAAqC,GAAIC,WAAW,IAAK;EACpE,MAAMC,WAAW,GAAGP,WAAW,CAC5BQ,IAAI,IACHF,WAAW,CAACG,oBAAoB,IAChCH,WAAW,CAACG,oBAAoB,CAACD,IAAI,CAAC,EACxC,CAACF,WAAW,CAAC,CACd;EAED,MAAMI,OAAO,GAAGV,WAAW,CACxBQ,IAAI,IACHF,WAAW,CAACK,gBAAgB,IAAIL,WAAW,CAACK,gBAAgB,CAACH,IAAI,CAAC,EACpE,CAACF,WAAW,CAAC,CACd;EAEDL,SAAS,CAAC,MAAM;IACd,MAAMW,YAAY,GAAG,IAAIV,kBAAkB,CAACC,aA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ACtD;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,YAAY,gDAIU,CAAA;AAEnC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,eAAO,MAAM,YAAY,gDAIY,CAAC;AAEtC,cAAc,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"qoreIdButton.android.d.ts","sourceRoot":"","sources":["../../src/qoreIdButton.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AASf,OAAO,KAAK,EAAmC,aAAa,EAAE,MAAM,SAAS,CAAC;AAqF9E,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAwChD,CAAC"}
1
+ {"version":3,"file":"qoreIdButton.android.d.ts","sourceRoot":"","sources":["../../src/qoreIdButton.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAgB,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA0DhD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qore-id/react-native-qoreid-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "QoreId React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -159,5 +159,8 @@
159
159
  }
160
160
  ]
161
161
  ]
162
+ },
163
+ "dependencies": {
164
+ "react-native-webview": "^12.2.0"
162
165
  }
163
166
  }
package/src/index.tsx CHANGED
@@ -5,6 +5,6 @@ export const QoreIdButton =
5
5
  Platform.OS === 'android'
6
6
  ? (require('./qoreIdButton.android')
7
7
  .QoreIdButton as React.FC<IQoreIdButton>)
8
- : {} as React.FC<IQoreIdButton> // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
8
+ : ({} as React.FC<IQoreIdButton>); // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
9
9
 
10
10
  export * from './utils';
@@ -1,70 +1,21 @@
1
- import React, {
2
- RefObject,
3
- forwardRef,
4
- useCallback,
5
- useEffect,
6
- useRef,
7
- } from 'react';
8
- import {
9
- UIManager,
10
- findNodeHandle,
11
- requireNativeComponent,
12
- View,
13
- NativeEventEmitter,
14
- NativeModules,
15
- } from 'react-native';
16
- import type { DataType, OnResultType, Options, IQoreIdButton } from './types';
1
+ import React, { useCallback, useEffect } from 'react';
2
+ import { NativeEventEmitter, NativeModules, Button } from 'react-native';
3
+ import type { OnResultType, IQoreIdButton } from './types';
17
4
 
18
- const QoreIdReactButtonManager = requireNativeComponent<{
19
- style?: { width?: number; height?: number };
20
- }>('QoreIdReactButtonManager');
21
-
22
- const Button = forwardRef<
23
- {
24
- style?: { width?: number; height?: number };
25
- },
26
- any
27
- >((_props, ref) => {
28
- return (
29
- <>
30
- <View
31
- style={{
32
- position: 'relative',
33
- margin: 'auto',
34
- height: 55,
35
- borderWidth: 1,
36
- }}
37
- >
38
- <QoreIdReactButtonManager
39
- //@ts-ignore
40
- ref={ref}
41
- />
42
- </View>
43
- </>
44
- );
45
- });
46
-
47
- function useQoreId(ref: RefObject<any>, options: Options) {
5
+ export const QoreIdButton: React.FC<IQoreIdButton> = (initialData) => {
48
6
  const onSubmitted = useCallback(
49
- (data) => options.onSubmitted && options.onSubmitted(data),
50
- [options]
7
+ (data) =>
8
+ initialData.onQoreIDSdkSubmitted &&
9
+ initialData.onQoreIDSdkSubmitted(data),
10
+ [initialData]
51
11
  );
12
+
52
13
  const onError = useCallback(
53
- (data) => options.onError && options.onError(data),
54
- [options]
14
+ (data) =>
15
+ initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data),
16
+ [initialData]
55
17
  );
56
18
 
57
- useEffect(() => {
58
- const buttonStyles = JSON.stringify(options.buttonProps);
59
- UIManager.dispatchViewManagerCommand(
60
- findNodeHandle(ref.current),
61
- // we are calling the 'create' command
62
- //@ts-ignore
63
- UIManager?.QoreIdReactButtonManager?.Commands?.create.toString(),
64
- [findNodeHandle(ref.current), options.config, buttonStyles]
65
- );
66
- }, []);
67
-
68
19
  useEffect(() => {
69
20
  const eventEmitter = new NativeEventEmitter(NativeModules.QoreidSdk);
70
21
  let eventListener = eventEmitter.addListener(
@@ -82,60 +33,31 @@ function useQoreId(ref: RefObject<any>, options: Options) {
82
33
  eventListener.remove();
83
34
  };
84
35
  }, []);
85
- }
86
-
87
- const onChangeData = (ref: any, data: DataType) => {
88
- const stringified = JSON.stringify(data);
89
36
 
90
- return useEffect(() => {
91
- UIManager.dispatchViewManagerCommand(
92
- findNodeHandle(ref.current),
93
- // we are calling the 'create' command
94
- //@ts-ignore
95
- UIManager?.QoreIdReactButtonManager?.Commands?.update.toString(),
96
- [stringified]
37
+ const startDSK = () => {
38
+ NativeModules.QoreidSdk.launchQoreId(
39
+ JSON.stringify({
40
+ config: {
41
+ flowId: initialData.flowId || 0,
42
+ customerRef: initialData.customerReference,
43
+ productCode: initialData.productCode!,
44
+ clientId: initialData.clientId,
45
+ },
46
+ applicantData: {
47
+ ...initialData.applicantData,
48
+ },
49
+ addressData: {
50
+ ...initialData.addressData,
51
+ },
52
+ acceptedDocuments: initialData.ocrAcceptedDocuments?.split(','),
53
+ identityData: { ...initialData.identityData },
54
+ })
97
55
  );
98
- }, [stringified]);
99
- };
100
-
101
- export const QoreIdButton: React.FC<IQoreIdButton> = (initialData) => {
102
- const ref = useRef(null);
103
-
104
- useQoreId(ref, {
105
- config: JSON.stringify({
106
- flowId: initialData.flowId || 0,
107
- customerRef: initialData.customerReference,
108
- productCode: initialData.productCode!,
109
- clientId: initialData.clientId,
110
- acceptedDocuments: initialData.ocrAcceptedDocuments?.split(','),
111
- }),
112
- onError(data) {
113
- initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data);
114
- },
115
- onSubmitted(data) {
116
- initialData.onQoreIDSdkSubmitted &&
117
- initialData.onQoreIDSdkSubmitted(data);
118
- },
119
- buttonProps: {
120
- title: initialData.title,
121
- },
122
- });
56
+ };
123
57
 
124
- onChangeData(ref, {
125
- config: {
126
- flowId: initialData.flowId || 0,
127
- customerRef: initialData.customerReference,
128
- productCode: initialData.productCode!,
129
- clientId: initialData.clientId,
130
- },
131
- applicantData: {
132
- ...initialData.applicantData,
133
- },
134
- addressData: {
135
- ...initialData.addressData,
136
- },
137
- acceptedDocuments: initialData.ocrAcceptedDocuments?.split(','),
138
- identityData: { ...initialData.identityData },
139
- });
140
- return <Button ref={ref} />;
58
+ return initialData.render ? (
59
+ initialData.render({ onPress: startDSK })
60
+ ) : (
61
+ <Button onPress={startDSK} title="Start Verification" />
62
+ );
141
63
  };
@@ -1,127 +0,0 @@
1
- package com.qoreidsdk
2
-
3
-
4
- import android.graphics.Color
5
- import android.os.Bundle
6
- import android.util.Log
7
- import android.view.LayoutInflater
8
- import android.view.View
9
- import android.view.ViewGroup
10
- import androidx.fragment.app.Fragment
11
- import com.google.gson.Gson
12
- import com.qoreid.sdk.core.QoreIDButton
13
- import com.qoreid.sdk.core.QoreIDParams
14
- import com.qoreid.sdk.core.models.AddressData
15
- import com.qoreid.sdk.core.models.ApplicantData
16
-
17
-
18
- class QoreIdReactButtonFragment : Fragment() {
19
- private lateinit var qoredIdButton: QoreIDButton
20
- var config: String = ""
21
- var buttonPropsString: String = "";
22
- private val gson = Gson()
23
-
24
- override fun onCreateView(
25
- inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
26
- ): View {
27
- super.onCreateView(inflater, container, savedInstanceState)
28
- qoredIdButton = QoreIDButton(requireContext())
29
- qoredIdButton.setText("Launch QoreID")
30
- if (buttonPropsString != "") {
31
- val buttonProps = gson.fromJson(buttonPropsString, StyleOptionsData::class.java)
32
- qoredIdButton.setText(buttonProps.title)
33
-
34
- }
35
-
36
- return qoredIdButton // this qoreIdButton could be any view that you want to render
37
- }
38
-
39
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
40
- super.onViewCreated(view, savedInstanceState)
41
- val configData = gson.fromJson(config, Config::class.java)
42
-
43
- val qoreIDParams = if (configData.flowId != 0L) {
44
- QoreIDParams()
45
- .clientId(configData.clientId)
46
- .customerReference(configData.customerRef)
47
- .ocrAcceptedDocuments(configData.acceptedDocuments)
48
- .workflow(configData.flowId!!)
49
- } else {
50
- QoreIDParams()
51
- .clientId(configData.clientId)
52
- .customerReference(configData.customerRef)
53
- .ocrAcceptedDocuments(configData.acceptedDocuments)
54
- .collection(configData.productCode)
55
- }
56
-
57
- qoredIdButton
58
- .params(qoreIDParams)
59
-
60
- }
61
-
62
-
63
- fun dataEventListener(jsonData: String) {
64
- Log.i("QoredID Event", "listening")
65
- Log.d("INITIALIze", ::qoredIdButton.isInitialized.toString())
66
- if (!::qoredIdButton.isInitialized) {
67
- return
68
- }
69
-
70
- val qoreIdJSData = gson.fromJson(jsonData, QoreIdJSData::class.java)
71
-
72
- Log.i("QOREIDPARAMS", qoreIdJSData.toString())
73
-
74
- val config = qoreIdJSData.config
75
- val apD = qoreIdJSData.applicantData
76
- val applicantData = ApplicantData(
77
- apD.firstName,
78
- apD.lastName,
79
- apD.phoneNumber,
80
- apD.middleName,
81
- apD.dob,
82
- apD.dob,
83
- apD.gender
84
- )
85
-
86
- val adD = qoreIdJSData.addressData
87
- val addressData = AddressData(
88
- adD.address,
89
- adD.city,
90
- adD.lga,
91
- adD.state,
92
- )
93
-
94
-
95
- val qoreIDParams = if (config.flowId != 0L) {
96
- QoreIDParams()
97
- .clientId(config.clientId)
98
- .customerReference(qoreIdJSData.config.customerRef)
99
- .inputData(applicantData, addressData)
100
- .ocrAcceptedDocuments(qoreIdJSData.acceptedDocuments)
101
- .workflow(config.flowId!!)
102
- } else {
103
- QoreIDParams()
104
- .clientId(config.clientId)
105
- .customerReference(qoreIdJSData.config.customerRef)
106
- .inputData(applicantData, addressData)
107
- .ocrAcceptedDocuments(qoreIdJSData.acceptedDocuments)
108
- .collection(config.productCode)
109
- }
110
-
111
- qoredIdButton
112
- .params(qoreIDParams)
113
-
114
- }
115
-
116
- companion object {
117
- private var instance: QoreIdReactButtonFragment? = null
118
-
119
- fun getInstance(): QoreIdReactButtonFragment {
120
- if (instance == null) {
121
- instance = QoreIdReactButtonFragment()
122
- }
123
- return instance as QoreIdReactButtonFragment
124
- }
125
- }
126
- }
127
-
@@ -1,169 +0,0 @@
1
- package com.qoreidsdk
2
-
3
-
4
- import android.util.Log
5
- import android.view.Choreographer
6
- import android.view.View
7
- import android.view.ViewGroup
8
- import android.view.ViewTreeObserver
9
- import android.widget.FrameLayout
10
- import androidx.fragment.app.FragmentActivity
11
- import com.facebook.react.bridge.ReactApplicationContext
12
- import com.facebook.react.bridge.ReadableArray
13
- import com.facebook.react.uimanager.ThemedReactContext
14
- import com.facebook.react.uimanager.ViewGroupManager
15
- import com.facebook.react.uimanager.annotations.ReactPropGroup
16
-
17
- class QoreIdReactButtonManager(
18
- private val reactContext: ReactApplicationContext
19
- ) : ViewGroupManager<FrameLayout>() {
20
- private var propWidth: Int? = null
21
- private var propHeight: Int? = null
22
-
23
- override fun getName() = REACT_CLASS
24
-
25
- /**
26
- * Return a FrameLayout which will later hold the Fragment
27
- */
28
- override fun createViewInstance(reactContext: ThemedReactContext): FrameLayout {
29
- return FrameLayout(reactContext)
30
- }
31
-
32
-
33
- /**
34
- * Map the "create, update" command to an integer
35
- */
36
- override fun getCommandsMap() = mapOf(
37
- "create" to COMMAND_CREATE,
38
- "update" to COMMAND_DATA_CHANGE,
39
- )
40
-
41
- /**
42
- * Handle "create, update" command (called from JS) and call createFragment method
43
- */
44
- override fun receiveCommand(
45
- root: FrameLayout, commandId: String, args: ReadableArray?
46
- ) {
47
- super.receiveCommand(root, commandId, args)
48
-
49
-
50
- when (commandId.toInt()) {
51
- COMMAND_CREATE -> {
52
- val reactNativeViewId = requireNotNull(args).getInt(0)
53
- var config = requireNotNull(args).getString(1)
54
- var btnString = args?.getString(2) ?: ""
55
-
56
- createFragment(root, reactNativeViewId, config, btnString)
57
- }
58
- COMMAND_DATA_CHANGE -> {
59
- val data = requireNotNull(args).getString(0)
60
- onDataChange(data);
61
- }
62
- }
63
- }
64
-
65
- @ReactPropGroup(names = ["width", "height"], customType = "Style")
66
- fun setStyle(view: FrameLayout, index: Int, value: Int) {
67
- if (index == 0) propWidth = value
68
- if (index == 1) propHeight = value
69
- }
70
-
71
-
72
- /**
73
- * Replace your React Native view with a custom fragment
74
- */
75
- fun createFragment(root: FrameLayout, reactNativeViewId: Int, config: String, btn: String?) {
76
- val parentView = root.findViewById<ViewGroup>(reactNativeViewId)
77
- setupLayout(parentView)
78
-
79
- val mFragment = QoreIdReactButtonFragment.getInstance()
80
- mFragment.config = config
81
-
82
- if(btn != null) {
83
- mFragment.buttonPropsString = btn
84
- }
85
- val activity = reactContext.currentActivity as FragmentActivity
86
- activity.supportFragmentManager.beginTransaction()
87
- .replace(reactNativeViewId, mFragment, reactNativeViewId.toString()).commit()
88
-
89
-
90
- // Add an `OnGlobalLayoutListener` to the parent view to detect when the view is unmounted
91
- parentView.viewTreeObserver.addOnGlobalLayoutListener(object :
92
- ViewTreeObserver.OnGlobalLayoutListener {
93
- override fun onGlobalLayout() {
94
- // Remove the fragment if the parent view is no longer attached to the window or its parent
95
- if (!parentView.isAttachedToWindow || parentView.parent == null) {
96
- val fragment =
97
- activity.supportFragmentManager.findFragmentById(reactNativeViewId)
98
- if (fragment != null) {
99
- activity.supportFragmentManager.beginTransaction().remove(fragment).commit()
100
- }
101
- parentView.viewTreeObserver.removeOnGlobalLayoutListener(this)
102
-
103
- }
104
- }
105
- })
106
-
107
- // Add an `OnAttachStateChangeListener` to the parent view to detect when the view is unmounted
108
- parentView.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
109
- override fun onViewAttachedToWindow(view: View) {
110
- // Do nothing
111
- }
112
-
113
- override fun onViewDetachedFromWindow(view: View) {
114
-
115
- }
116
- })
117
- }
118
-
119
- // function for listening on that changes from RN app
120
- fun onDataChange(str: String) {
121
- val mFragment = QoreIdReactButtonFragment.getInstance()
122
- mFragment.dataEventListener(str)
123
- }
124
-
125
- fun setupLayout(view: View) {
126
- Choreographer.getInstance().postFrameCallback(object : Choreographer.FrameCallback {
127
- override fun doFrame(frameTimeNanos: Long) {
128
- manuallyLayoutChildren(view)
129
- view.viewTreeObserver.dispatchOnGlobalLayout()
130
- Choreographer.getInstance().postFrameCallback(this)
131
- }
132
- })
133
- }
134
-
135
- /**
136
- * Layout all children properly
137
- */
138
- private fun manuallyLayoutChildren(view: View) {
139
-
140
- // Get the parent view's dimensions
141
- val parentWidth =
142
- view.parent as? View ?: return // return if the parent is null or not a view
143
- val width = parentWidth.width
144
-
145
- val parentHeight =
146
- view.parent as? View ?: return // return if the parent is null or not a view
147
- val height = parentHeight.height
148
-
149
- view.measure(
150
- View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY),
151
- View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY)
152
- )
153
-
154
- // Set the view's layout params to match parent width and height
155
- val layoutParams = view.layoutParams
156
- layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
157
- layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
158
- view.layoutParams = layoutParams
159
-
160
- view.layout(0, 0, width, height)
161
- }
162
-
163
-
164
- companion object {
165
- private const val REACT_CLASS = "QoreIdReactButtonManager"
166
- private const val COMMAND_CREATE = 1
167
- private const val COMMAND_DATA_CHANGE = 2
168
- }
169
- }
@@ -1,7 +0,0 @@
1
- package com.qoreidsdk
2
-
3
- interface StyleOption {
4
- var color:String
5
- var backgroundColor:String
6
- var title: String
7
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=react-native-qoreid-sdk.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["react-native-qoreid-sdk.d.ts"],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=react-native-qoreid-sdk.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["react-native-qoreid-sdk.d.ts"],"mappings":""}
@@ -1,3 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- import { UIManager, findNodeHandle, requireNativeComponent, View, NativeEventEmitter, NativeModules, Platform } from 'react-native';
3
-