react-native-okhi 1.2.13 → 1.2.15
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/android/build.gradle +1 -1
- package/lib/commonjs/OkCollect/app.json +1 -1
- package/lib/commonjs/OkCore/index.js +27 -15
- package/lib/commonjs/OkCore/index.js.map +1 -1
- package/lib/module/OkCollect/app.json +1 -1
- package/lib/module/OkCore/index.js +20 -7
- package/lib/module/OkCore/index.js.map +1 -1
- package/package.json +1 -1
- package/src/OkCollect/app.json +1 -1
- package/src/OkCore/index.ts +32 -10
package/android/build.gradle
CHANGED
|
@@ -127,7 +127,7 @@ dependencies {
|
|
|
127
127
|
//noinspection GradleDynamicVersion
|
|
128
128
|
implementation "com.facebook.react:react-native:+"
|
|
129
129
|
implementation 'io.okhi.android:core:1.7.17'
|
|
130
|
-
implementation 'io.okhi.android:okverify:1.9.
|
|
130
|
+
implementation 'io.okhi.android:okverify:1.9.44'
|
|
131
131
|
// From node_modules
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -12,27 +12,27 @@ exports.initialize = initialize;
|
|
|
12
12
|
var _reactNative = require("react-native");
|
|
13
13
|
var _OkHiNativeModule = require("../OkHiNativeModule");
|
|
14
14
|
var _helpers = require("./_helpers");
|
|
15
|
-
var
|
|
16
|
-
Object.keys(
|
|
15
|
+
var _OkHiException = require("./OkHiException");
|
|
16
|
+
Object.keys(_OkHiException).forEach(function (key) {
|
|
17
17
|
if (key === "default" || key === "__esModule") return;
|
|
18
18
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
-
if (key in exports && exports[key] ===
|
|
19
|
+
if (key in exports && exports[key] === _OkHiException[key]) return;
|
|
20
20
|
Object.defineProperty(exports, key, {
|
|
21
21
|
enumerable: true,
|
|
22
22
|
get: function () {
|
|
23
|
-
return
|
|
23
|
+
return _OkHiException[key];
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
|
-
var
|
|
28
|
-
Object.keys(
|
|
27
|
+
var _types = require("./types");
|
|
28
|
+
Object.keys(_types).forEach(function (key) {
|
|
29
29
|
if (key === "default" || key === "__esModule") return;
|
|
30
30
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
-
if (key in exports && exports[key] ===
|
|
31
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
32
32
|
Object.defineProperty(exports, key, {
|
|
33
33
|
enumerable: true,
|
|
34
34
|
get: function () {
|
|
35
|
-
return
|
|
35
|
+
return _types[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
@@ -61,7 +61,12 @@ Object.keys(_Helpers).forEach(function (key) {
|
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
let okhiApplicationConfiguration;
|
|
64
|
-
|
|
64
|
+
function validateConfiguration(config) {
|
|
65
|
+
if (typeof config !== 'object' || config === null || !config.credentials || typeof config.credentials.branchId !== 'string' || config.credentials.branchId.trim().length === 0 || typeof config.credentials.clientKey !== 'string' || config.credentials.clientKey.trim().length === 0) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
65
70
|
/**
|
|
66
71
|
* Initializes the OkHi library with provided API keys
|
|
67
72
|
* @param {Object} configuration A configuration object with your OkHi credentials as well as library settings
|
|
@@ -69,15 +74,22 @@ let okhiApplicationConfiguration;
|
|
|
69
74
|
*/
|
|
70
75
|
function initialize(configuration) {
|
|
71
76
|
return (0, _helpers.errorHandler)(async () => {
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
const isValidConfig = validateConfiguration(configuration);
|
|
78
|
+
if (!isValidConfig) {
|
|
79
|
+
throw new _OkHiException.OkHiException({
|
|
80
|
+
code: _OkHiException.OkHiException.UNAUTHORIZED_CODE,
|
|
81
|
+
message: 'Invalid OkHi configuration provided.'
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
85
|
+
await _OkHiNativeModule.OkHiNativeModule.initializeIOS(configuration.credentials.branchId, configuration.credentials.clientKey, configuration.context.mode);
|
|
86
|
+
if (_reactNative.AppState.currentState !== 'background') {
|
|
78
87
|
await _OkHiNativeModule.OkHiNativeModule.onStart();
|
|
79
88
|
}
|
|
89
|
+
} else {
|
|
90
|
+
await _OkHiNativeModule.OkHiNativeModule.initialize(JSON.stringify(configuration));
|
|
80
91
|
}
|
|
92
|
+
okhiApplicationConfiguration = configuration;
|
|
81
93
|
});
|
|
82
94
|
}
|
|
83
95
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_OkHiNativeModule","_helpers","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_OkHiNativeModule","_helpers","_OkHiException","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_types","_OkHiMode","_Helpers","okhiApplicationConfiguration","validateConfiguration","config","credentials","branchId","trim","length","clientKey","initialize","configuration","errorHandler","isValidConfig","OkHiException","code","UNAUTHORIZED_CODE","message","Platform","OS","OkHiNativeModule","initializeIOS","context","mode","AppState","currentState","onStart","JSON","stringify","getApplicationConfiguration","_okhiApplicationConfi","_okhiApplicationConfi2","auth","token","getAuthToken","error"],"sources":["index.ts"],"sourcesContent":["import { Platform, AppState } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkHiApplicationConfiguration } from './types';\nimport { errorHandler } from './_helpers';\nimport type { AuthApplicationConfig } from './_types';\nimport { OkHiException } from './OkHiException';\n\nexport * from './types';\nexport * from './OkHiException';\nexport * from './OkHiMode';\nexport * from './Helpers';\n\nlet okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;\n\nfunction validateConfiguration(config: OkHiApplicationConfiguration) {\n if (\n typeof config !== 'object' ||\n config === null ||\n !config.credentials ||\n typeof config.credentials.branchId !== 'string' ||\n config.credentials.branchId.trim().length === 0 ||\n typeof config.credentials.clientKey !== 'string' ||\n config.credentials.clientKey.trim().length === 0\n ) {\n return false;\n }\n return true;\n}\n/**\n * Initializes the OkHi library with provided API keys\n * @param {Object} configuration A configuration object with your OkHi credentials as well as library settings\n * @returns {Promise<void>} A promise that resolves when initialization is successful\n */\nexport function initialize(\n configuration: OkHiApplicationConfiguration\n): Promise<void> {\n return errorHandler(async () => {\n const isValidConfig = validateConfiguration(configuration);\n if (!isValidConfig) {\n throw new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: 'Invalid OkHi configuration provided.',\n });\n }\n if (Platform.OS === 'ios') {\n await OkHiNativeModule.initializeIOS(\n configuration.credentials.branchId,\n configuration.credentials.clientKey,\n configuration.context.mode\n );\n if (AppState.currentState !== 'background') {\n await OkHiNativeModule.onStart();\n }\n } else {\n await OkHiNativeModule.initialize(JSON.stringify(configuration));\n }\n okhiApplicationConfiguration = configuration;\n });\n}\n\n/**\n * Obtains your current running configuration\n * @returns {Promise<void>} A promise that resolves with your application configuration\n */\nexport async function getApplicationConfiguration(): Promise<AuthApplicationConfig | null> {\n try {\n if (typeof okhiApplicationConfiguration === 'object') {\n return {\n ...okhiApplicationConfiguration,\n auth: {\n token: await OkHiNativeModule.getAuthToken(\n okhiApplicationConfiguration?.credentials.branchId || '',\n okhiApplicationConfiguration?.credentials.clientKey || ''\n ),\n },\n };\n }\n return null;\n } catch (error) {\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,cAAA,GAAAH,OAAA;AAGAI,MAAA,CAAAC,IAAA,CAAAF,cAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,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ACC,aAAa,CAClCV,aAAa,CAACN,WAAW,CAACC,QAAQ,EAClCK,aAAa,CAACN,WAAW,CAACI,SAAS,EACnCE,aAAa,CAACW,OAAO,CAACC,IACxB,CAAC;MACD,IAAIC,qBAAQ,CAACC,YAAY,KAAK,YAAY,EAAE;QAC1C,MAAML,kCAAgB,CAACM,OAAO,CAAC,CAAC;MAClC;IACF,CAAC,MAAM;MACL,MAAMN,kCAAgB,CAACV,UAAU,CAACiB,IAAI,CAACC,SAAS,CAACjB,aAAa,CAAC,CAAC;IAClE;IACAT,4BAA4B,GAAGS,aAAa;EAC9C,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACO,eAAekB,2BAA2BA,CAAA,EAA0C;EACzF,IAAI;IACF,IAAI,OAAO3B,4BAA4B,KAAK,QAAQ,EAAE;MAAA,IAAA4B,qBAAA,EAAAC,sBAAA;MACpD,OAAO;QACL,GAAG7B,4BAA4B;QAC/B8B,IAAI,EAAE;UACJC,KAAK,EAAE,MAAMb,kCAAgB,CAACc,YAAY,CACxC,EAAAJ,qBAAA,GAAA5B,4BAA4B,cAAA4B,qBAAA,uBAA5BA,qBAAA,CAA8BzB,WAAW,CAACC,QAAQ,KAAI,EAAE,EACxD,EAAAyB,sBAAA,GAAA7B,4BAA4B,cAAA6B,sBAAA,uBAA5BA,sBAAA,CAA8B1B,WAAW,CAACI,SAAS,KAAI,EACzD;QACF;MACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAO0B,KAAK,EAAE;IACd,MAAMA,KAAK;EACb;AACF"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { Platform, AppState } from 'react-native';
|
|
2
2
|
import { OkHiNativeModule } from '../OkHiNativeModule';
|
|
3
3
|
import { errorHandler } from './_helpers';
|
|
4
|
+
import { OkHiException } from './OkHiException';
|
|
4
5
|
export * from './types';
|
|
5
6
|
export * from './OkHiException';
|
|
6
7
|
export * from './OkHiMode';
|
|
7
8
|
export * from './Helpers';
|
|
8
9
|
let okhiApplicationConfiguration;
|
|
9
|
-
|
|
10
|
+
function validateConfiguration(config) {
|
|
11
|
+
if (typeof config !== 'object' || config === null || !config.credentials || typeof config.credentials.branchId !== 'string' || config.credentials.branchId.trim().length === 0 || typeof config.credentials.clientKey !== 'string' || config.credentials.clientKey.trim().length === 0) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
10
16
|
/**
|
|
11
17
|
* Initializes the OkHi library with provided API keys
|
|
12
18
|
* @param {Object} configuration A configuration object with your OkHi credentials as well as library settings
|
|
@@ -14,15 +20,22 @@ let okhiApplicationConfiguration;
|
|
|
14
20
|
*/
|
|
15
21
|
export function initialize(configuration) {
|
|
16
22
|
return errorHandler(async () => {
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const isValidConfig = validateConfiguration(configuration);
|
|
24
|
+
if (!isValidConfig) {
|
|
25
|
+
throw new OkHiException({
|
|
26
|
+
code: OkHiException.UNAUTHORIZED_CODE,
|
|
27
|
+
message: 'Invalid OkHi configuration provided.'
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (Platform.OS === 'ios') {
|
|
31
|
+
await OkHiNativeModule.initializeIOS(configuration.credentials.branchId, configuration.credentials.clientKey, configuration.context.mode);
|
|
32
|
+
if (AppState.currentState !== 'background') {
|
|
23
33
|
await OkHiNativeModule.onStart();
|
|
24
34
|
}
|
|
35
|
+
} else {
|
|
36
|
+
await OkHiNativeModule.initialize(JSON.stringify(configuration));
|
|
25
37
|
}
|
|
38
|
+
okhiApplicationConfiguration = configuration;
|
|
26
39
|
});
|
|
27
40
|
}
|
|
28
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","AppState","OkHiNativeModule","errorHandler","okhiApplicationConfiguration","
|
|
1
|
+
{"version":3,"names":["Platform","AppState","OkHiNativeModule","errorHandler","OkHiException","okhiApplicationConfiguration","validateConfiguration","config","credentials","branchId","trim","length","clientKey","initialize","configuration","isValidConfig","code","UNAUTHORIZED_CODE","message","OS","initializeIOS","context","mode","currentState","onStart","JSON","stringify","getApplicationConfiguration","_okhiApplicationConfi","_okhiApplicationConfi2","auth","token","getAuthToken","error"],"sources":["index.ts"],"sourcesContent":["import { Platform, AppState } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkHiApplicationConfiguration } from './types';\nimport { errorHandler } from './_helpers';\nimport type { AuthApplicationConfig } from './_types';\nimport { OkHiException } from './OkHiException';\n\nexport * from './types';\nexport * from './OkHiException';\nexport * from './OkHiMode';\nexport * from './Helpers';\n\nlet okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;\n\nfunction validateConfiguration(config: OkHiApplicationConfiguration) {\n if (\n typeof config !== 'object' ||\n config === null ||\n !config.credentials ||\n typeof config.credentials.branchId !== 'string' ||\n config.credentials.branchId.trim().length === 0 ||\n typeof config.credentials.clientKey !== 'string' ||\n config.credentials.clientKey.trim().length === 0\n ) {\n return false;\n }\n return true;\n}\n/**\n * Initializes the OkHi library with provided API keys\n * @param {Object} configuration A configuration object with your OkHi credentials as well as library settings\n * @returns {Promise<void>} A promise that resolves when initialization is successful\n */\nexport function initialize(\n configuration: OkHiApplicationConfiguration\n): Promise<void> {\n return errorHandler(async () => {\n const isValidConfig = validateConfiguration(configuration);\n if (!isValidConfig) {\n throw new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: 'Invalid OkHi configuration provided.',\n });\n }\n if (Platform.OS === 'ios') {\n await OkHiNativeModule.initializeIOS(\n configuration.credentials.branchId,\n configuration.credentials.clientKey,\n configuration.context.mode\n );\n if (AppState.currentState !== 'background') {\n await OkHiNativeModule.onStart();\n }\n } else {\n await OkHiNativeModule.initialize(JSON.stringify(configuration));\n }\n okhiApplicationConfiguration = configuration;\n });\n}\n\n/**\n * Obtains your current running configuration\n * @returns {Promise<void>} A promise that resolves with your application configuration\n */\nexport async function getApplicationConfiguration(): Promise<AuthApplicationConfig | null> {\n try {\n if (typeof okhiApplicationConfiguration === 'object') {\n return {\n ...okhiApplicationConfiguration,\n auth: {\n token: await OkHiNativeModule.getAuthToken(\n okhiApplicationConfiguration?.credentials.branchId || '',\n okhiApplicationConfiguration?.credentials.clientKey || ''\n ),\n },\n };\n }\n return null;\n } catch (error) {\n throw error;\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,QAAQ,QAAQ,cAAc;AACjD,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,SAASC,YAAY,QAAQ,YAAY;AAEzC,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,WAAW;AAEzB,IAAIC,4BAAsE;AAE1E,SAASC,qBAAqBA,CAACC,MAAoC,EAAE;EACnE,IACE,OAAOA,MAAM,KAAK,QAAQ,IAC1BA,MAAM,KAAK,IAAI,IACf,CAACA,MAAM,CAACC,WAAW,IACnB,OAAOD,MAAM,CAACC,WAAW,CAACC,QAAQ,KAAK,QAAQ,IAC/CF,MAAM,CAACC,WAAW,CAACC,QAAQ,CAACC,IAAI,CAAC,CAAC,CAACC,MAAM,KAAK,CAAC,IAC/C,OAAOJ,MAAM,CAACC,WAAW,CAACI,SAAS,KAAK,QAAQ,IAChDL,MAAM,CAACC,WAAW,CAACI,SAAS,CAACF,IAAI,CAAC,CAAC,CAACC,MAAM,KAAK,CAAC,EAChD;IACA,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,UAAUA,CACxBC,aAA2C,EAC5B;EACf,OAAOX,YAAY,CAAC,YAAY;IAC9B,MAAMY,aAAa,GAAGT,qBAAqB,CAACQ,aAAa,CAAC;IAC1D,IAAI,CAACC,aAAa,EAAE;MAClB,MAAM,IAAIX,aAAa,CAAC;QACtBY,IAAI,EAAEZ,aAAa,CAACa,iBAAiB;QACrCC,OAAO,EAAE;MACX,CAAC,CAAC;IACJ;IACA,IAAIlB,QAAQ,CAACmB,EAAE,KAAK,KAAK,EAAE;MACzB,MAAMjB,gBAAgB,CAACkB,aAAa,CAClCN,aAAa,CAACN,WAAW,CAACC,QAAQ,EAClCK,aAAa,CAACN,WAAW,CAACI,SAAS,EACnCE,aAAa,CAACO,OAAO,CAACC,IACxB,CAAC;MACD,IAAIrB,QAAQ,CAACsB,YAAY,KAAK,YAAY,EAAE;QAC1C,MAAMrB,gBAAgB,CAACsB,OAAO,CAAC,CAAC;MAClC;IACF,CAAC,MAAM;MACL,MAAMtB,gBAAgB,CAACW,UAAU,CAACY,IAAI,CAACC,SAAS,CAACZ,aAAa,CAAC,CAAC;IAClE;IACAT,4BAA4B,GAAGS,aAAa;EAC9C,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAea,2BAA2BA,CAAA,EAA0C;EACzF,IAAI;IACF,IAAI,OAAOtB,4BAA4B,KAAK,QAAQ,EAAE;MAAA,IAAAuB,qBAAA,EAAAC,sBAAA;MACpD,OAAO;QACL,GAAGxB,4BAA4B;QAC/ByB,IAAI,EAAE;UACJC,KAAK,EAAE,MAAM7B,gBAAgB,CAAC8B,YAAY,CACxC,EAAAJ,qBAAA,GAAAvB,4BAA4B,cAAAuB,qBAAA,uBAA5BA,qBAAA,CAA8BpB,WAAW,CAACC,QAAQ,KAAI,EAAE,EACxD,EAAAoB,sBAAA,GAAAxB,4BAA4B,cAAAwB,sBAAA,uBAA5BA,sBAAA,CAA8BrB,WAAW,CAACI,SAAS,KAAI,EACzD;QACF;MACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOqB,KAAK,EAAE;IACd,MAAMA,KAAK;EACb;AACF"}
|
package/package.json
CHANGED
package/src/OkCollect/app.json
CHANGED
package/src/OkCore/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { OkHiNativeModule } from '../OkHiNativeModule';
|
|
|
3
3
|
import type { OkHiApplicationConfiguration } from './types';
|
|
4
4
|
import { errorHandler } from './_helpers';
|
|
5
5
|
import type { AuthApplicationConfig } from './_types';
|
|
6
|
+
import { OkHiException } from './OkHiException';
|
|
6
7
|
|
|
7
8
|
export * from './types';
|
|
8
9
|
export * from './OkHiException';
|
|
@@ -11,6 +12,20 @@ export * from './Helpers';
|
|
|
11
12
|
|
|
12
13
|
let okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;
|
|
13
14
|
|
|
15
|
+
function validateConfiguration(config: OkHiApplicationConfiguration) {
|
|
16
|
+
if (
|
|
17
|
+
typeof config !== 'object' ||
|
|
18
|
+
config === null ||
|
|
19
|
+
!config.credentials ||
|
|
20
|
+
typeof config.credentials.branchId !== 'string' ||
|
|
21
|
+
config.credentials.branchId.trim().length === 0 ||
|
|
22
|
+
typeof config.credentials.clientKey !== 'string' ||
|
|
23
|
+
config.credentials.clientKey.trim().length === 0
|
|
24
|
+
) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
14
29
|
/**
|
|
15
30
|
* Initializes the OkHi library with provided API keys
|
|
16
31
|
* @param {Object} configuration A configuration object with your OkHi credentials as well as library settings
|
|
@@ -20,19 +35,26 @@ export function initialize(
|
|
|
20
35
|
configuration: OkHiApplicationConfiguration
|
|
21
36
|
): Promise<void> {
|
|
22
37
|
return errorHandler(async () => {
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
const isValidConfig = validateConfiguration(configuration);
|
|
39
|
+
if (!isValidConfig) {
|
|
40
|
+
throw new OkHiException({
|
|
41
|
+
code: OkHiException.UNAUTHORIZED_CODE,
|
|
42
|
+
message: 'Invalid OkHi configuration provided.',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (Platform.OS === 'ios') {
|
|
46
|
+
await OkHiNativeModule.initializeIOS(
|
|
47
|
+
configuration.credentials.branchId,
|
|
48
|
+
configuration.credentials.clientKey,
|
|
49
|
+
configuration.context.mode
|
|
50
|
+
);
|
|
51
|
+
if (AppState.currentState !== 'background') {
|
|
33
52
|
await OkHiNativeModule.onStart();
|
|
34
53
|
}
|
|
54
|
+
} else {
|
|
55
|
+
await OkHiNativeModule.initialize(JSON.stringify(configuration));
|
|
35
56
|
}
|
|
57
|
+
okhiApplicationConfiguration = configuration;
|
|
36
58
|
});
|
|
37
59
|
}
|
|
38
60
|
|