@qore-id/react-native-qoreid-sdk 1.0.7 → 1.0.9

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Emmanuel Ugwuoke
3
+ Copyright (c) 2023 QoreID
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
6
6
  in the Software without restriction, including without limitation the rights
package/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  QoreID React Native SDK
2
2
 
3
-
4
3
  Link to [documentation](https://docs.qoreid.com/docs/qoreid-react-native-sdk)
5
4
 
6
5
  ## Installation
@@ -8,6 +7,7 @@ Link to [documentation](https://docs.qoreid.com/docs/qoreid-react-native-sdk)
8
7
  ```c npm
9
8
  npm install --save @qore-id/react-native-qoreid-sdk
10
9
  ```
10
+
11
11
  ```c yarn
12
12
  yarn add @qore-id/react-native-qoreid-sdk
13
13
  ```
@@ -27,6 +27,7 @@ Add the following to your `app/build.gradle`
27
27
  ```
28
28
 
29
29
  Add this snippet of code to your `~/java/com.<app name>/MainActivity`
30
+
30
31
  ```java
31
32
  @Override
32
33
  protected void onCreate(Bundle savedInstanceState) {
@@ -50,13 +51,16 @@ From your root directory
50
51
  ```sh
51
52
  npm i react-native-webview
52
53
  ``` -->
54
+
53
55
  ## Permissions
56
+
54
57
  Certain services on QoreID require device permissions to work properly. Follow the instructions [here](https://docs.qoreid.com/docs/permissions) to add the required permissions to your `~/android/app/src/main/AndroidManifest.xml` file.
55
58
 
56
59
  Verifind required permissions
60
+
57
61
  ```xml
58
62
  ...
59
- <!-- Required for Verifind -->
63
+ <!-- Required for Verifind -->
60
64
  <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />
61
65
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
62
66
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
@@ -64,7 +68,67 @@ Verifind required permissions
64
68
  ...
65
69
  ```
66
70
 
67
- ## Usage
71
+ ## Usage
72
+
73
+ ```tsx
74
+ //verify.tsx
75
+ import React from 'react';
76
+ import { Button, View } from 'react-native';
77
+ import { QoreIdSdk } from '@qore-id/react-native-qoreid-sdk';
78
+
79
+ function App() {
80
+
81
+ const onError = (data) => {
82
+ console.error(data);
83
+ Alert.alert('Error', data);
84
+ };
85
+
86
+ const onSuccess = (data) => {
87
+ console.debug(data);
88
+ Alert.alert('Sumitted', data);
89
+ };
90
+
91
+ QoreIdSdk.events(onSuccess, onError);
92
+
93
+ function onSubmit() {
94
+ const formData = {
95
+ flowId: parseInt(flowId),
96
+ clientId: clientId,
97
+ productCode: selectedProductId,
98
+ customerReference: customerRef,
99
+ applicantData: {
100
+ firstName: firstName,
101
+ middleName: middleName,
102
+ lastName: lastName,
103
+ gender: gender,
104
+ phoneNumber: phoneNumber,
105
+ email: email,
106
+ },
107
+ identityData: {
108
+ idType: idCardType,
109
+ idNumber: idNumber,
110
+ },
111
+ addressData: {
112
+ address: phyAddress,
113
+ city: city,
114
+ lga: lga,
115
+ },
116
+ ocrAcceptedDocuments:
117
+ 'DRIVERS_LICENSE_NGA,VOTERS_CARD_NGA,NIN_SLIP_NGA,PASSPORT_NGA',
118
+ };
119
+
120
+ QoreIdSdk.launchQoreId(formData);
121
+ }
122
+
123
+ return (
124
+ <View>
125
+ <Button title="Launch QoreIdSdk" onPress={onSubmit} />
126
+ </View>
127
+ );
128
+ }
129
+ ```
130
+
131
+ You can also use the QoreIdButton component to trigger verifications (which will be deprecated in the next major release):
68
132
 
69
133
  ```tsx
70
134
  //verify.tsx
@@ -73,7 +137,7 @@ import { QoreIdButton } from '@qore-id/react-native-qoreid-sdk';
73
137
 
74
138
 
75
139
  function App() {
76
-
140
+
77
141
  const customButton = ({ onPress }) => <Button onPress={onPress} title="QoreId Button" />
78
142
 
79
143
  const onError = (data) => {
@@ -126,8 +190,6 @@ function App() {
126
190
 
127
191
  ```
128
192
 
129
-
130
-
131
193
  ### Utilities
132
194
 
133
195
  QoreId SDK exposes utilities that you can easily use
@@ -141,7 +203,7 @@ function App() {
141
203
 
142
204
  // Array of string
143
205
  //For more information check -> https://docs.qoreid.com/docs/product-codes
144
- const productIds = utils.productCodes;
206
+ const productIds = utils.productCodes;
145
207
 
146
208
 
147
209
  //An array of accepted documents in a specific country
@@ -150,4 +212,12 @@ function App() {
150
212
  ...
151
213
  }
152
214
 
153
- ```
215
+ ```
216
+
217
+ ## CHANGE LOGS
218
+
219
+ #### 1.0.9
220
+
221
+ - Added qoreid initialization function. You can now launche the sdk in your code implementation - offering you more control.
222
+ - Addition of event listener `QoreIdSdk.events` to listen to events from the sdk.
223
+ - QoreIdButton component will be deprecated in the next major release. Use `QoreIdSdk.launchQoreId` instead.
@@ -59,7 +59,6 @@ class QoreidSdkModule(val reactContext: ReactApplicationContext) :
59
59
  return NAME
60
60
  }
61
61
 
62
-
63
62
  @ReactMethod
64
63
  fun launchQoreId(jsonData: String) {
65
64
 
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- QoreIdButton: true
7
+ QoreIdButton: true,
8
+ QoreIdSdk: true
8
9
  };
9
- exports.QoreIdButton = void 0;
10
+ exports.QoreIdSdk = exports.QoreIdButton = void 0;
10
11
  var _reactNative = require("react-native");
12
+ var _react = _interopRequireDefault(require("react"));
11
13
  var _utils = require("./utils");
12
14
  Object.keys(_utils).forEach(function (key) {
13
15
  if (key === "default" || key === "__esModule") return;
@@ -20,6 +22,39 @@ Object.keys(_utils).forEach(function (key) {
20
22
  }
21
23
  });
22
24
  });
23
- const QoreIdButton = _reactNative.Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdButton : {}; // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
25
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
+ //Safe fail implementation for iOS
27
+ const QoreIdButtonIOS = initialData => {
28
+ console.info('No implementation for iOS');
29
+ return initialData.render && initialData.render({
30
+ onPress: () => {}
31
+ }) || /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
32
+ style: {
33
+ flex: 1,
34
+ justifyContent: 'center',
35
+ alignItems: 'center',
36
+ paddingHorizontal: 10,
37
+ paddingVertical: 5
38
+ }
39
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
40
+ style: {
41
+ color: 'blue'
42
+ }
43
+ }, "Start QoreID"));
44
+ };
45
+
46
+ // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
47
+
48
+ const QoreIdSdkIOS = {
49
+ launchQoreId: _data => {
50
+ console.info('No implementation for iOS');
51
+ },
52
+ events: (_onSuccess, _onError) => {
53
+ console.info('No implementation for iOS');
54
+ }
55
+ };
56
+ const QoreIdButton = _reactNative.Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdButton : QoreIdButtonIOS;
24
57
  exports.QoreIdButton = QoreIdButton;
58
+ const QoreIdSdk = _reactNative.Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdSdk : QoreIdSdkIOS;
59
+ exports.QoreIdSdk = QoreIdSdk;
25
60
  //# sourceMappingURL=index.js.map
@@ -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,GACd,CAAC,CAA6B,CAAC,CAAC;AAAAJ,OAAA,CAAAI,YAAA,GAAAA,YAAA"}
1
+ {"version":3,"names":["_reactNative","require","_react","_interopRequireDefault","_utils","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","obj","__esModule","default","QoreIdButtonIOS","initialData","console","info","render","onPress","createElement","TouchableOpacity","style","flex","justifyContent","alignItems","paddingHorizontal","paddingVertical","Text","color","QoreIdSdkIOS","launchQoreId","_data","events","_onSuccess","_onError","QoreIdButton","Platform","OS","QoreIdSdk"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAwBA,IAAAG,MAAA,GAAAH,OAAA;AAAAI,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,GA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C4C,SAAS,GAC3CT,YAAY;AAACvB,OAAA,CAAAgC,SAAA,GAAAA,SAAA"}
@@ -3,29 +3,78 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.QoreIdButton = void 0;
6
+ exports.QoreIdSdk = exports.QoreIdButton = void 0;
7
7
  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 QoreIdSdk = {
12
+ /**
13
+ * lauches QoreID SDK
14
+ * @param initialData - data to launch Qore ID SDK
15
+ * @requires QoreIdSdk native module installed
16
+ */
17
+ launchQoreId(initialData) {
18
+ var _initialData$ocrAccep;
19
+ _reactNative.NativeModules.QoreidSdk.launchQoreId(JSON.stringify({
20
+ config: {
21
+ flowId: initialData.flowId || 0,
22
+ customerRef: initialData.customerReference,
23
+ productCode: initialData.productCode,
24
+ clientId: initialData.clientId
25
+ },
26
+ applicantData: {
27
+ ...initialData.applicantData
28
+ },
29
+ addressData: {
30
+ ...initialData.addressData
31
+ },
32
+ acceptedDocuments: (_initialData$ocrAccep = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep === void 0 ? void 0 : _initialData$ocrAccep.split(','),
33
+ identityData: {
34
+ ...initialData.identityData
35
+ }
36
+ }));
37
+ },
38
+ /**
39
+ * QoreIdSdk events listener. It takes callbacks to handle success and error events
40
+ * @param onSuccess Called on success with result
41
+ * @param onError Called on error with error object
42
+ */
43
+ events(onSuccess, onError) {
44
+ (0, _react.useEffect)(() => {
45
+ const eventEmitter = _reactNative.Platform.OS === 'android' ? new _reactNative.NativeEventEmitter() : new _reactNative.NativeEventEmitter(_reactNative.NativeModules.QoreidSdk);
46
+ let eventListener = eventEmitter.addListener('onResult', event => {
47
+ if (event !== null && event !== void 0 && event.code) {
48
+ onError === null || onError === void 0 ? void 0 : onError(event);
49
+ return;
50
+ }
51
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event);
52
+ });
53
+ return () => {
54
+ eventEmitter.removeSubscription(eventListener);
55
+ };
56
+ }, []);
57
+ }
58
+ };
59
+ exports.QoreIdSdk = QoreIdSdk;
11
60
  const QoreIdButton = initialData => {
12
61
  const onSubmitted = (0, _react.useCallback)(data => initialData.onQoreIDSdkSubmitted && initialData.onQoreIDSdkSubmitted(data), [initialData]);
13
62
  const onError = (0, _react.useCallback)(data => initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data), [initialData]);
14
63
  (0, _react.useEffect)(() => {
15
- const eventEmitter = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.QoreidSdk);
64
+ const eventEmitter = _reactNative.Platform.OS === 'android' ? new _reactNative.NativeEventEmitter() : new _reactNative.NativeEventEmitter(_reactNative.NativeModules.QoreidSdk);
16
65
  let eventListener = eventEmitter.addListener('onResult', event => {
17
66
  if (event !== null && event !== void 0 && event.code) {
18
- onError && onError(event);
67
+ onError === null || onError === void 0 ? void 0 : onError(event);
19
68
  return;
20
69
  }
21
- onSubmitted && onSubmitted(event);
70
+ onSubmitted === null || onSubmitted === void 0 ? void 0 : onSubmitted(event);
22
71
  });
23
72
  return () => {
24
- eventListener.remove();
73
+ eventEmitter.removeSubscription(eventListener);
25
74
  };
26
75
  }, []);
27
76
  const startDSK = () => {
28
- var _initialData$ocrAccep;
77
+ var _initialData$ocrAccep2;
29
78
  _reactNative.NativeModules.QoreidSdk.launchQoreId(JSON.stringify({
30
79
  config: {
31
80
  flowId: initialData.flowId || 0,
@@ -39,7 +88,7 @@ const QoreIdButton = initialData => {
39
88
  addressData: {
40
89
  ...initialData.addressData
41
90
  },
42
- acceptedDocuments: (_initialData$ocrAccep = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep === void 0 ? void 0 : _initialData$ocrAccep.split(','),
91
+ acceptedDocuments: (_initialData$ocrAccep2 = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep2 === void 0 ? void 0 : _initialData$ocrAccep2.split(','),
43
92
  identityData: {
44
93
  ...initialData.identityData
45
94
  }
@@ -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","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,OA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AAW,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
+ {"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","QoreIdSdk","launchQoreId","initialData","_initialData$ocrAccep","NativeModules","QoreidSdk","JSON","stringify","config","flowId","customerRef","customerReference","productCode","clientId","applicantData","addressData","acceptedDocuments","ocrAcceptedDocuments","split","identityData","events","onSuccess","onError","useEffect","eventEmitter","Platform","OS","NativeEventEmitter","eventListener","addListener","event","code","removeSubscription","exports","QoreIdButton","onSubmitted","useCallback","data","onQoreIDSdkSubmitted","onQoreIDSdkError","startDSK","_initialData$ocrAccep2","render","onPress","createElement","Button","title"],"sourceRoot":"../../src","sources":["qoreIdButton.android.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAKsB,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,GA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AC;MAC/DC,YAAY,EAAE;QAAE,GAAGjB,WAAW,CAACiB;MAAa;IAC9C,CAAC,CAAC,CACH;EACH,CAAC;EAED,OAAOjB,WAAW,CAACwC,MAAM,GACvBxC,WAAW,CAACwC,MAAM,CAAC;IAAEC,OAAO,EAAEH;EAAS,CAAC,CAAC,gBAEzClE,MAAA,CAAAW,OAAA,CAAA2D,aAAA,CAACnE,YAAA,CAAAoE,MAAM;IAACF,OAAO,EAAEH,QAAS;IAACM,KAAK,EAAC;EAAoB,EACtD;AACH,CAAC;AAACb,OAAA,CAAAC,YAAA,GAAAA,YAAA"}
@@ -1,5 +1,37 @@
1
- import { Platform } from 'react-native';
2
- export const QoreIdButton = Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdButton : {}; // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
1
+ import { Platform, Text, TouchableOpacity } from 'react-native';
2
+ import React from 'react';
3
+
4
+ //Safe fail implementation for iOS
5
+ const QoreIdButtonIOS = initialData => {
6
+ console.info('No implementation for iOS');
7
+ return initialData.render && initialData.render({
8
+ onPress: () => {}
9
+ }) || /*#__PURE__*/React.createElement(TouchableOpacity, {
10
+ style: {
11
+ flex: 1,
12
+ justifyContent: 'center',
13
+ alignItems: 'center',
14
+ paddingHorizontal: 10,
15
+ paddingVertical: 5
16
+ }
17
+ }, /*#__PURE__*/React.createElement(Text, {
18
+ style: {
19
+ color: 'blue'
20
+ }
21
+ }, "Start QoreID"));
22
+ };
23
+
24
+ // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
3
25
 
4
26
  export * from './utils';
27
+ const QoreIdSdkIOS = {
28
+ launchQoreId: _data => {
29
+ console.info('No implementation for iOS');
30
+ },
31
+ events: (_onSuccess, _onError) => {
32
+ console.info('No implementation for iOS');
33
+ }
34
+ };
35
+ export const QoreIdButton = Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdButton : QoreIdButtonIOS;
36
+ export const QoreIdSdk = Platform.OS === 'android' ? require('./qoreIdButton.android').QoreIdSdk : QoreIdSdkIOS;
5
37
  //# sourceMappingURL=index.js.map
@@ -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,GACd,CAAC,CAA6B,CAAC,CAAC;;AAEvC,cAAc,SAAS"}
1
+ {"version":3,"names":["Platform","Text","TouchableOpacity","React","QoreIdButtonIOS","initialData","console","info","render","onPress","createElement","style","flex","justifyContent","alignItems","paddingHorizontal","paddingVertical","color","QoreIdSdkIOS","launchQoreId","_data","events","_onSuccess","_onError","QoreIdButton","OS","require","QoreIdSdk"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,IAAI,EAAEC,gBAAgB,QAAQ,cAAc;AAE/D,OAAOC,KAAK,MAAM,OAAO;;AAEzB;AACA,MAAMC,eAAwC,GAAIC,WAAW,IAAK;EAChEC,OAAO,CAACC,IAAI,CAAC,2BAA2B,CAAC;EACzC,OACGF,WAAW,CAACG,MAAM,IAAIH,WAAW,CAACG,MAAM,CAAC;IAAEC,OAAO,EAAEA,CAAA,KAAM,CAAC;EAAE,CAAC,CAAC,iBAC9DN,KAAA,CAAAO,aAAA,CAACR,gBAAgB;IACfS,KAAK,EAAE;MACLC,IAAI,EAAE,CAAC;MACPC,cAAc,EAAE,QAAQ;MACxBC,UAAU,EAAE,QAAQ;MACpBC,iBAAiB,EAAE,EAAE;MACrBC,eAAe,EAAE;IACnB;EAAE,gBAEFb,KAAA,CAAAO,aAAA,CAACT,IAAI;IAACU,KAAK,EAAE;MAAEM,KAAK,EAAE;IAAO;EAAE,GAAC,cAAY,CAAO,CAEtD;AAEL,CAAC;;AAED;;AAEA,cAAc,SAAS;AAEvB,MAAMC,YAAY,GAAG;EACnBC,YAAY,EAAGC,KAAc,IAAK;IAChCd,OAAO,CAACC,IAAI,CAAC,2BAA2B,CAAC;EAC3C,CAAC;EACDc,MAAM,EAAEA,CACNC,UAAmC,EACnCC,QAAiC,KAC9B;IACHjB,OAAO,CAACC,IAAI,CAAC,2BAA2B,CAAC;EAC3C;AACF,CAAC;AAED,OAAO,MAAMiB,YAAY,GACvBxB,QAAQ,CAACyB,EAAE,KAAK,SAAS,GACrBC,OAAO,CAAC,wBAAwB,CAAC,CAACF,YAAY,GAC9CpB,eAAe;AAErB,OAAO,MAAMuB,SAAS,GACpB3B,QAAQ,CAACyB,EAAE,KAAK,SAAS,GACrBC,OAAO,CAAC,wBAAwB,CAAC,CAACC,SAAS,GAC3CT,YAAY"}
@@ -1,23 +1,71 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
- import { NativeEventEmitter, NativeModules, Button } from 'react-native';
2
+ import { NativeEventEmitter, NativeModules, Button, Platform } from 'react-native';
3
+ export const QoreIdSdk = {
4
+ /**
5
+ * lauches QoreID SDK
6
+ * @param initialData - data to launch Qore ID SDK
7
+ * @requires QoreIdSdk native module installed
8
+ */
9
+ launchQoreId(initialData) {
10
+ var _initialData$ocrAccep;
11
+ NativeModules.QoreidSdk.launchQoreId(JSON.stringify({
12
+ config: {
13
+ flowId: initialData.flowId || 0,
14
+ customerRef: initialData.customerReference,
15
+ productCode: initialData.productCode,
16
+ clientId: initialData.clientId
17
+ },
18
+ applicantData: {
19
+ ...initialData.applicantData
20
+ },
21
+ addressData: {
22
+ ...initialData.addressData
23
+ },
24
+ acceptedDocuments: (_initialData$ocrAccep = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep === void 0 ? void 0 : _initialData$ocrAccep.split(','),
25
+ identityData: {
26
+ ...initialData.identityData
27
+ }
28
+ }));
29
+ },
30
+ /**
31
+ * QoreIdSdk events listener. It takes callbacks to handle success and error events
32
+ * @param onSuccess Called on success with result
33
+ * @param onError Called on error with error object
34
+ */
35
+ events(onSuccess, onError) {
36
+ useEffect(() => {
37
+ const eventEmitter = Platform.OS === 'android' ? new NativeEventEmitter() : new NativeEventEmitter(NativeModules.QoreidSdk);
38
+ let eventListener = eventEmitter.addListener('onResult', event => {
39
+ if (event !== null && event !== void 0 && event.code) {
40
+ onError === null || onError === void 0 ? void 0 : onError(event);
41
+ return;
42
+ }
43
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(event);
44
+ });
45
+ return () => {
46
+ eventEmitter.removeSubscription(eventListener);
47
+ };
48
+ }, []);
49
+ }
50
+ };
3
51
  export const QoreIdButton = initialData => {
4
52
  const onSubmitted = useCallback(data => initialData.onQoreIDSdkSubmitted && initialData.onQoreIDSdkSubmitted(data), [initialData]);
5
53
  const onError = useCallback(data => initialData.onQoreIDSdkError && initialData.onQoreIDSdkError(data), [initialData]);
6
54
  useEffect(() => {
7
- const eventEmitter = new NativeEventEmitter(NativeModules.QoreidSdk);
55
+ const eventEmitter = Platform.OS === 'android' ? new NativeEventEmitter() : new NativeEventEmitter(NativeModules.QoreidSdk);
8
56
  let eventListener = eventEmitter.addListener('onResult', event => {
9
57
  if (event !== null && event !== void 0 && event.code) {
10
- onError && onError(event);
58
+ onError === null || onError === void 0 ? void 0 : onError(event);
11
59
  return;
12
60
  }
13
- onSubmitted && onSubmitted(event);
61
+ onSubmitted === null || onSubmitted === void 0 ? void 0 : onSubmitted(event);
14
62
  });
15
63
  return () => {
16
- eventListener.remove();
64
+ eventEmitter.removeSubscription(eventListener);
17
65
  };
18
66
  }, []);
19
67
  const startDSK = () => {
20
- var _initialData$ocrAccep;
68
+ var _initialData$ocrAccep2;
21
69
  NativeModules.QoreidSdk.launchQoreId(JSON.stringify({
22
70
  config: {
23
71
  flowId: initialData.flowId || 0,
@@ -31,7 +79,7 @@ export const QoreIdButton = initialData => {
31
79
  addressData: {
32
80
  ...initialData.addressData
33
81
  },
34
- acceptedDocuments: (_initialData$ocrAccep = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep === void 0 ? void 0 : _initialData$ocrAccep.split(','),
82
+ acceptedDocuments: (_initialData$ocrAccep2 = initialData.ocrAcceptedDocuments) === null || _initialData$ocrAccep2 === void 0 ? void 0 : _initialData$ocrAccep2.split(','),
35
83
  identityData: {
36
84
  ...initialData.identityData
37
85
  }
@@ -1 +1 @@
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,aAAa,CAACU,SAAS,CAAC;IACpE,IAAIC,aAAa,GAAGF,YAAY,CAACG,WAAW,CAC1C,UAAU,EACTC,KAAmB,IAAK;MACvB,IAAIA,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEC,IAAI,EAAE;QACfP,OAAO,IAAIA,OAAO,CAACM,KAAK,CAAC;QACzB;MACF;MACAT,WAAW,IAAIA,WAAW,CAACS,KAAK,CAAC;IACnC,CAAC,CACF;IAED,OAAO,MAAM;MACXF,aAAa,CAACI,MAAM,EAAE;IACxB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,QAAQ,GAAGA,CAAA,KAAM;IAAA,IAAAC,qBAAA;IACrBjB,aAAa,CAACU,SAAS,CAACQ,YAAY,CAClCC,IAAI,CAACC,SAAS,CAAC;MACbC,MAAM,EAAE;QACNC,MAAM,EAAEnB,WAAW,CAACmB,MAAM,IAAI,CAAC;QAC/BC,WAAW,EAAEpB,WAAW,CAACqB,iBAAiB;QAC1CC,WAAW,EAAEtB,WAAW,CAACsB,WAAY;QACrCC,QAAQ,EAAEvB,WAAW,CAACuB;MACxB,CAAC;MACDC,aAAa,EAAE;QACb,GAAGxB,WAAW,CAACwB;MACjB,CAAC;MACDC,WAAW,EAAE;QACX,GAAGzB,WAAW,CAACyB;MACjB,CAAC;MACDC,iBAAiB,GAAAZ,qBAAA,GAAEd,WAAW,CAAC2B,oBAAoB,cAAAb,qBAAA,uBAAhCA,qBAAA,CAAkCc,KAAK,CAAC,GAAG,CAAC;MAC/DC,YAAY,EAAE;QAAE,GAAG7B,WAAW,CAAC6B;MAAa;IAC9C,CAAC,CAAC,CACH;EACH,CAAC;EAED,OAAO7B,WAAW,CAAC8B,MAAM,GACvB9B,WAAW,CAAC8B,MAAM,CAAC;IAAEC,OAAO,EAAElB;EAAS,CAAC,CAAC,gBAEzCpB,KAAA,CAAAuC,aAAA,CAAClC,MAAM;IAACiC,OAAO,EAAElB,QAAS;IAACoB,KAAK,EAAC;EAAoB,EACtD;AACH,CAAC"}
1
+ {"version":3,"names":["React","useCallback","useEffect","NativeEventEmitter","NativeModules","Button","Platform","QoreIdSdk","launchQoreId","initialData","_initialData$ocrAccep","QoreidSdk","JSON","stringify","config","flowId","customerRef","customerReference","productCode","clientId","applicantData","addressData","acceptedDocuments","ocrAcceptedDocuments","split","identityData","events","onSuccess","onError","eventEmitter","OS","eventListener","addListener","event","code","removeSubscription","QoreIdButton","onSubmitted","data","onQoreIDSdkSubmitted","onQoreIDSdkError","startDSK","_initialData$ocrAccep2","render","onPress","createElement","title"],"sourceRoot":"../../src","sources":["qoreIdButton.android.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,QAAQ,OAAO;AACrD,SACEC,kBAAkB,EAClBC,aAAa,EACbC,MAAM,EACNC,QAAQ,QACH,cAAc;AAGrB,OAAO,MAAMC,SAAS,GAAG;EACvB;AACF;AACA;AACA;AACA;EACEC,YAAYA,CACVC,WAOC,EACD;IAAA,IAAAC,qBAAA;IACAN,aAAa,CAACO,SAAS,CAACH,YAAY,CAClCI,IAAI,CAACC,SAAS,CAAC;MACbC,MAAM,EAAE;QACNC,MAAM,EAAEN,WAAW,CAACM,MAAM,IAAI,CAAC;QAC/BC,WAAW,EAAEP,WAAW,CAACQ,iBAAiB;QAC1CC,WAAW,EAAET,WAAW,CAACS,WAAY;QACrCC,QAAQ,EAAEV,WAAW,CAACU;MACxB,CAAC;MACDC,aAAa,EAAE;QACb,GAAGX,WAAW,CAACW;MACjB,CAAC;MACDC,WAAW,EAAE;QACX,GAAGZ,WAAW,CAACY;MACjB,CAAC;MACDC,iBAAiB,GAAAZ,qBAAA,GAAED,WAAW,CAACc,oBAAoB,cAAAb,qBAAA,uBAAhCA,qBAAA,CAAkCc,KAAK,CAAC,GAAG,CAAC;MAC/DC,YAAY,EAAE;QAAE,GAAGhB,WAAW,CAACgB;MAAa;IAC9C,CAAC,CAAC,CACH;EACH,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,MAAMA,CACJC,SAAqD,EACrDC,OAAqC,EACrC;IACA1B,SAAS,CAAC,MAAM;MACd,MAAM2B,YAAY,GAChBvB,QAAQ,CAACwB,EAAE,KAAK,SAAS,GACrB,IAA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AXA,WAAW,uBAAXA,WAAW,CAAGJ,KAAK,CAAC;IACtB,CAAC,CACF;IAED,OAAO,MAAM;MACXJ,YAAY,CAACM,kBAAkB,CAACJ,aAAa,CAAC;IAChD,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMU,QAAQ,GAAGA,CAAA,KAAM;IAAA,IAAAC,sBAAA;IACrBtC,aAAa,CAACO,SAAS,CAACH,YAAY,CAClCI,IAAI,CAACC,SAAS,CAAC;MACbC,MAAM,EAAE;QACNC,MAAM,EAAEN,WAAW,CAACM,MAAM,IAAI,CAAC;QAC/BC,WAAW,EAAEP,WAAW,CAACQ,iBAAiB;QAC1CC,WAAW,EAAET,WAAW,CAACS,WAAY;QACrCC,QAAQ,EAAEV,WAAW,CAACU;MACxB,CAAC;MACDC,aAAa,EAAE;QACb,GAAGX,WAAW,CAACW;MACjB,CAAC;MACDC,WAAW,EAAE;QACX,GAAGZ,WAAW,CAACY;MACjB,CAAC;MACDC,iBAAiB,GAAAoB,sBAAA,GAAEjC,WAAW,CAACc,oBAAoB,cAAAmB,sBAAA,uBAAhCA,sBAAA,CAAkClB,KAAK,CAAC,GAAG,CAAC;MAC/DC,YAAY,EAAE;QAAE,GAAGhB,WAAW,CAACgB;MAAa;IAC9C,CAAC,CAAC,CACH;EACH,CAAC;EAED,OAAOhB,WAAW,CAACkC,MAAM,GACvBlC,WAAW,CAACkC,MAAM,CAAC;IAAEC,OAAO,EAAEH;EAAS,CAAC,CAAC,gBAEzCzC,KAAA,CAAA6C,aAAA,CAACxC,MAAM;IAACuC,OAAO,EAAEH,QAAS;IAACK,KAAK,EAAC;EAAoB,EACtD;AACH,CAAC"}
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- import type { IQoreIdButton } from './types';
3
- export declare const QoreIdButton: import("react").FC<IQoreIdButton<JSX.Element>>;
4
1
  export * from './utils';
2
+ export declare const QoreIdButton: any;
3
+ export declare const QoreIdSdk: any;
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -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,gDAIY,CAAC;AAEtC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AA0BA,cAAc,SAAS,CAAC;AAcxB,eAAO,MAAM,YAAY,KAGJ,CAAC;AAEtB,eAAO,MAAM,SAAS,KAGJ,CAAC"}
@@ -1,4 +1,18 @@
1
1
  import React from 'react';
2
- import type { IQoreIdButton } from './types';
2
+ import type { OnResultType, IQoreIdButton } from './types';
3
+ export declare const QoreIdSdk: {
4
+ /**
5
+ * lauches QoreID SDK
6
+ * @param initialData - data to launch Qore ID SDK
7
+ * @requires QoreIdSdk native module installed
8
+ */
9
+ launchQoreId(initialData: Omit<IQoreIdButton, 'render' | 'title' | 'onQoreIDSdkSubmitted' | 'onQoreIDSdkError' | 'onQoreIDSdkClosed'>): void;
10
+ /**
11
+ * QoreIdSdk events listener. It takes callbacks to handle success and error events
12
+ * @param onSuccess Called on success with result
13
+ * @param onError Called on error with error object
14
+ */
15
+ events(onSuccess: (data: Omit<OnResultType, 'code'>) => void, onError: (data: OnResultType) => void): void;
16
+ };
3
17
  export declare const QoreIdButton: React.FC<IQoreIdButton>;
4
18
  //# sourceMappingURL=qoreIdButton.android.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"qoreIdButton.android.d.ts","sourceRoot":"","sources":["../../src/qoreIdButton.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AAOtD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,SAAS;IACpB;;;;OAIG;8BAEY,KACX,aAAa,EACX,QAAQ,GACR,OAAO,GACP,sBAAsB,GACtB,kBAAkB,GAClB,mBAAmB,CACtB;IAsBH;;;;OAIG;6BAEiB,KAAK,YAAY,EAAE,MAAM,CAAC,KAAK,IAAI,kBACrC,YAAY,KAAK,IAAI;CAuBxC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA6DhD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qore-id/react-native-qoreid-sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "QoreId React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/index.tsx CHANGED
@@ -1,10 +1,49 @@
1
- import { Platform } from 'react-native';
1
+ import { Platform, Text, TouchableOpacity } from 'react-native';
2
2
  import type { IQoreIdButton } from './types';
3
+ import React from 'react';
4
+
5
+ //Safe fail implementation for iOS
6
+ const QoreIdButtonIOS: React.FC<IQoreIdButton> = (initialData) => {
7
+ console.info('No implementation for iOS');
8
+ return (
9
+ (initialData.render && initialData.render({ onPress: () => {} })) || (
10
+ <TouchableOpacity
11
+ style={{
12
+ flex: 1,
13
+ justifyContent: 'center',
14
+ alignItems: 'center',
15
+ paddingHorizontal: 10,
16
+ paddingVertical: 5,
17
+ }}
18
+ >
19
+ <Text style={{ color: 'blue' }}>Start QoreID</Text>
20
+ </TouchableOpacity>
21
+ )
22
+ );
23
+ };
24
+
25
+ // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
26
+
27
+ export * from './utils';
28
+
29
+ const QoreIdSdkIOS = {
30
+ launchQoreId: (_data: unknown) => {
31
+ console.info('No implementation for iOS');
32
+ },
33
+ events: (
34
+ _onSuccess: (data: unknown) => void,
35
+ _onError: (data: unknown) => void
36
+ ) => {
37
+ console.info('No implementation for iOS');
38
+ },
39
+ };
3
40
 
4
41
  export const QoreIdButton =
5
42
  Platform.OS === 'android'
6
- ? (require('./qoreIdButton.android')
7
- .QoreIdButton as React.FC<IQoreIdButton>)
8
- : ({} as React.FC<IQoreIdButton>); // (require('./qoreIdButton.ios').QoreIdButton as React.FC<IQoreIdButton>);
43
+ ? require('./qoreIdButton.android').QoreIdButton
44
+ : QoreIdButtonIOS;
9
45
 
10
- export * from './utils';
46
+ export const QoreIdSdk =
47
+ Platform.OS === 'android'
48
+ ? require('./qoreIdButton.android').QoreIdSdk
49
+ : QoreIdSdkIOS;
@@ -1,7 +1,80 @@
1
1
  import React, { useCallback, useEffect } from 'react';
2
- import { NativeEventEmitter, NativeModules, Button } from 'react-native';
2
+ import {
3
+ NativeEventEmitter,
4
+ NativeModules,
5
+ Button,
6
+ Platform,
7
+ } from 'react-native';
3
8
  import type { OnResultType, IQoreIdButton } from './types';
4
9
 
10
+ export const QoreIdSdk = {
11
+ /**
12
+ * lauches QoreID SDK
13
+ * @param initialData - data to launch Qore ID SDK
14
+ * @requires QoreIdSdk native module installed
15
+ */
16
+ launchQoreId(
17
+ initialData: Omit<
18
+ IQoreIdButton,
19
+ | 'render'
20
+ | 'title'
21
+ | 'onQoreIDSdkSubmitted'
22
+ | 'onQoreIDSdkError'
23
+ | 'onQoreIDSdkClosed'
24
+ >
25
+ ) {
26
+ NativeModules.QoreidSdk.launchQoreId(
27
+ JSON.stringify({
28
+ config: {
29
+ flowId: initialData.flowId || 0,
30
+ customerRef: initialData.customerReference,
31
+ productCode: initialData.productCode!,
32
+ clientId: initialData.clientId,
33
+ },
34
+ applicantData: {
35
+ ...initialData.applicantData,
36
+ },
37
+ addressData: {
38
+ ...initialData.addressData,
39
+ },
40
+ acceptedDocuments: initialData.ocrAcceptedDocuments?.split(','),
41
+ identityData: { ...initialData.identityData },
42
+ })
43
+ );
44
+ },
45
+
46
+ /**
47
+ * QoreIdSdk events listener. It takes callbacks to handle success and error events
48
+ * @param onSuccess Called on success with result
49
+ * @param onError Called on error with error object
50
+ */
51
+ events(
52
+ onSuccess: (data: Omit<OnResultType, 'code'>) => void,
53
+ onError: (data: OnResultType) => void
54
+ ) {
55
+ useEffect(() => {
56
+ const eventEmitter =
57
+ Platform.OS === 'android'
58
+ ? new NativeEventEmitter()
59
+ : new NativeEventEmitter(NativeModules.QoreidSdk);
60
+ let eventListener = eventEmitter.addListener(
61
+ 'onResult',
62
+ (event: OnResultType) => {
63
+ if (event?.code) {
64
+ onError?.(event);
65
+ return;
66
+ }
67
+ onSuccess?.(event);
68
+ }
69
+ );
70
+
71
+ return () => {
72
+ eventEmitter.removeSubscription(eventListener);
73
+ };
74
+ }, []);
75
+ },
76
+ };
77
+
5
78
  export const QoreIdButton: React.FC<IQoreIdButton> = (initialData) => {
6
79
  const onSubmitted = useCallback(
7
80
  (data) =>
@@ -17,20 +90,23 @@ export const QoreIdButton: React.FC<IQoreIdButton> = (initialData) => {
17
90
  );
18
91
 
19
92
  useEffect(() => {
20
- const eventEmitter = new NativeEventEmitter(NativeModules.QoreidSdk);
93
+ const eventEmitter =
94
+ Platform.OS === 'android'
95
+ ? new NativeEventEmitter()
96
+ : new NativeEventEmitter(NativeModules.QoreidSdk);
21
97
  let eventListener = eventEmitter.addListener(
22
98
  'onResult',
23
99
  (event: OnResultType) => {
24
100
  if (event?.code) {
25
- onError && onError(event);
101
+ onError?.(event);
26
102
  return;
27
103
  }
28
- onSubmitted && onSubmitted(event);
104
+ onSubmitted?.(event);
29
105
  }
30
106
  );
31
107
 
32
108
  return () => {
33
- eventListener.remove();
109
+ eventEmitter.removeSubscription(eventListener);
34
110
  };
35
111
  }, []);
36
112