react-native-okhi 1.2.31 → 1.2.32-beta.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/LICENSE +1 -1
- package/README.md +34 -4
- package/ReactNativeOkhi.podspec +21 -0
- package/android/build.gradle +38 -99
- package/android/gradle.properties +3 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/okhi/OkhiModule.kt +336 -0
- package/android/src/main/java/com/okhi/OkhiPackage.kt +33 -0
- package/ios/OkHiWrapper.swift +348 -0
- package/ios/Okhi.h +5 -0
- package/ios/Okhi.mm +170 -0
- package/lib/commonjs/NativeOkhi.js +9 -0
- package/lib/commonjs/NativeOkhi.js.map +1 -0
- package/lib/commonjs/index.js +234 -28
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/NativeOkhi.js +5 -0
- package/lib/module/NativeOkhi.js.map +1 -0
- package/lib/module/index.js +221 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeOkhi.d.ts +25 -0
- package/lib/typescript/commonjs/src/NativeOkhi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +22 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +81 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeOkhi.d.ts +25 -0
- package/lib/typescript/module/src/NativeOkhi.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +22 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +81 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +91 -112
- package/src/NativeOkhi.ts +68 -0
- package/src/index.tsx +271 -3
- package/src/types.ts +90 -0
- package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +0 -389
- package/android/src/main/java/com/reactnativeokhi/OkhiPackage.java +0 -28
- package/ios/OkHiExtension.swift +0 -27
- package/ios/OkHiStruct.swift +0 -29
- package/ios/Okhi-Bridging-Header.h +0 -3
- package/ios/Okhi.m +0 -62
- package/ios/Okhi.swift +0 -325
- package/ios/Okhi.xcodeproj/project.pbxproj +0 -283
- package/lib/commonjs/OkCollect/Helpers.js +0 -40
- package/lib/commonjs/OkCollect/Helpers.js.map +0 -1
- package/lib/commonjs/OkCollect/OkHiLocationManager.js +0 -305
- package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +0 -1
- package/lib/commonjs/OkCollect/Spinner.js +0 -27
- package/lib/commonjs/OkCollect/Spinner.js.map +0 -1
- package/lib/commonjs/OkCollect/Util.js +0 -226
- package/lib/commonjs/OkCollect/Util.js.map +0 -1
- package/lib/commonjs/OkCollect/app.json +0 -4
- package/lib/commonjs/OkCollect/index.js +0 -47
- package/lib/commonjs/OkCollect/index.js.map +0 -1
- package/lib/commonjs/OkCollect/types.js +0 -6
- package/lib/commonjs/OkCollect/types.js.map +0 -1
- package/lib/commonjs/OkCore/Helpers.js +0 -386
- package/lib/commonjs/OkCore/Helpers.js.map +0 -1
- package/lib/commonjs/OkCore/OkHiException.js +0 -96
- package/lib/commonjs/OkCore/OkHiException.js.map +0 -1
- package/lib/commonjs/OkCore/OkHiMode.js +0 -14
- package/lib/commonjs/OkCore/OkHiMode.js.map +0 -1
- package/lib/commonjs/OkCore/_helpers.js +0 -41
- package/lib/commonjs/OkCore/_helpers.js.map +0 -1
- package/lib/commonjs/OkCore/_types.js +0 -2
- package/lib/commonjs/OkCore/_types.js.map +0 -1
- package/lib/commonjs/OkCore/index.js +0 -119
- package/lib/commonjs/OkCore/index.js.map +0 -1
- package/lib/commonjs/OkCore/types.js +0 -6
- package/lib/commonjs/OkCore/types.js.map +0 -1
- package/lib/commonjs/OkHiNativeModule/index.js +0 -19
- package/lib/commonjs/OkHiNativeModule/index.js.map +0 -1
- package/lib/commonjs/OkVerify/index.js +0 -211
- package/lib/commonjs/OkVerify/index.js.map +0 -1
- package/lib/commonjs/OkVerify/types.js.map +0 -1
- package/lib/module/OkCollect/Helpers.js +0 -34
- package/lib/module/OkCollect/Helpers.js.map +0 -1
- package/lib/module/OkCollect/OkHiLocationManager.js +0 -298
- package/lib/module/OkCollect/OkHiLocationManager.js.map +0 -1
- package/lib/module/OkCollect/Spinner.js +0 -20
- package/lib/module/OkCollect/Spinner.js.map +0 -1
- package/lib/module/OkCollect/Util.js +0 -214
- package/lib/module/OkCollect/Util.js.map +0 -1
- package/lib/module/OkCollect/app.json +0 -4
- package/lib/module/OkCollect/index.js +0 -4
- package/lib/module/OkCollect/index.js.map +0 -1
- package/lib/module/OkCollect/types.js +0 -2
- package/lib/module/OkCollect/types.js.map +0 -1
- package/lib/module/OkCore/Helpers.js +0 -363
- package/lib/module/OkCore/Helpers.js.map +0 -1
- package/lib/module/OkCore/OkHiException.js +0 -89
- package/lib/module/OkCore/OkHiException.js.map +0 -1
- package/lib/module/OkCore/OkHiMode.js +0 -8
- package/lib/module/OkCore/OkHiMode.js.map +0 -1
- package/lib/module/OkCore/_helpers.js +0 -34
- package/lib/module/OkCore/_helpers.js.map +0 -1
- package/lib/module/OkCore/_types.js +0 -2
- package/lib/module/OkCore/_types.js.map +0 -1
- package/lib/module/OkCore/index.js +0 -65
- package/lib/module/OkCore/index.js.map +0 -1
- package/lib/module/OkCore/types.js +0 -2
- package/lib/module/OkCore/types.js.map +0 -1
- package/lib/module/OkHiNativeModule/index.js +0 -13
- package/lib/module/OkHiNativeModule/index.js.map +0 -1
- package/lib/module/OkVerify/index.js +0 -195
- package/lib/module/OkVerify/index.js.map +0 -1
- package/lib/module/OkVerify/types.js +0 -2
- package/lib/module/OkVerify/types.js.map +0 -1
- package/lib/typescript/OkCollect/Helpers.d.ts +0 -9
- package/lib/typescript/OkCollect/OkHiLocationManager.d.ts +0 -7
- package/lib/typescript/OkCollect/Spinner.d.ts +0 -5
- package/lib/typescript/OkCollect/Util.d.ts +0 -31
- package/lib/typescript/OkCollect/index.d.ts +0 -3
- package/lib/typescript/OkCollect/types.d.ts +0 -139
- package/lib/typescript/OkCore/Helpers.d.ts +0 -95
- package/lib/typescript/OkCore/OkHiException.d.ts +0 -81
- package/lib/typescript/OkCore/OkHiMode.d.ts +0 -7
- package/lib/typescript/OkCore/_helpers.d.ts +0 -3
- package/lib/typescript/OkCore/_types.d.ts +0 -38
- package/lib/typescript/OkCore/index.d.ts +0 -17
- package/lib/typescript/OkCore/types.d.ts +0 -203
- package/lib/typescript/OkHiNativeModule/index.d.ts +0 -48
- package/lib/typescript/OkVerify/index.d.ts +0 -65
- package/lib/typescript/OkVerify/types.d.ts +0 -0
- package/lib/typescript/index.d.ts +0 -3
- package/react-native-okhi.podspec +0 -35
- package/src/OkCollect/Helpers.ts +0 -53
- package/src/OkCollect/OkHiLocationManager.tsx +0 -391
- package/src/OkCollect/Spinner.tsx +0 -18
- package/src/OkCollect/Util.ts +0 -270
- package/src/OkCollect/app.json +0 -4
- package/src/OkCollect/index.ts +0 -3
- package/src/OkCollect/types.ts +0 -154
- package/src/OkCore/Helpers.ts +0 -477
- package/src/OkCore/OkHiException.ts +0 -93
- package/src/OkCore/OkHiMode.ts +0 -7
- package/src/OkCore/_helpers.ts +0 -47
- package/src/OkCore/_types.ts +0 -37
- package/src/OkCore/index.ts +0 -87
- package/src/OkCore/types.ts +0 -235
- package/src/OkHiNativeModule/index.ts +0 -92
- package/src/OkVerify/index.ts +0 -259
- package/src/OkVerify/types.ts +0 -0
- /package/lib/commonjs/{OkVerify/types.js → types.js} +0 -0
package/src/OkVerify/index.ts
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
isBackgroundLocationPermissionGranted,
|
|
4
|
-
isGooglePlayServicesAvailable,
|
|
5
|
-
isLocationServicesEnabled,
|
|
6
|
-
requestBackgroundLocationPermission,
|
|
7
|
-
requestEnableGooglePlayServices,
|
|
8
|
-
requestEnableLocationServices,
|
|
9
|
-
requestLocationPermission,
|
|
10
|
-
isLocationPermissionGranted,
|
|
11
|
-
} from '../OkCore/Helpers';
|
|
12
|
-
import { errorHandler, isValidPlatform } from '../OkCore/_helpers';
|
|
13
|
-
import { OkHiNativeModule } from '../OkHiNativeModule';
|
|
14
|
-
import type { OkCollectSuccessResponse } from '../OkCollect/types';
|
|
15
|
-
import { OkHiException } from '../OkCore/OkHiException';
|
|
16
|
-
import type { UsageType } from '../OkCore';
|
|
17
|
-
/**
|
|
18
|
-
* Starts verification for a particular address
|
|
19
|
-
* @param {string} phoneNumber A users phone number
|
|
20
|
-
* @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.
|
|
21
|
-
* @param {number} lat The latitude of the created address
|
|
22
|
-
* @param {number} lon The longitude of the created address
|
|
23
|
-
* @param usageTypes - Optional. An array of verification types that specifies the mode of verification.
|
|
24
|
-
* Can include "physical" and/or "digital" as valid values.
|
|
25
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
26
|
-
*/
|
|
27
|
-
export const start = (
|
|
28
|
-
token: string,
|
|
29
|
-
phoneNumber: string,
|
|
30
|
-
okhiUserId: string,
|
|
31
|
-
locationId: string,
|
|
32
|
-
lat: number,
|
|
33
|
-
lon: number,
|
|
34
|
-
usageTypes?: UsageType
|
|
35
|
-
) => {
|
|
36
|
-
return isValidPlatform(() => {
|
|
37
|
-
const utypes: UsageType = Array.isArray(usageTypes)
|
|
38
|
-
? usageTypes
|
|
39
|
-
: ['digital_verification'];
|
|
40
|
-
return OkHiNativeModule.startAddressVerification(
|
|
41
|
-
token,
|
|
42
|
-
phoneNumber,
|
|
43
|
-
okhiUserId,
|
|
44
|
-
locationId,
|
|
45
|
-
lat,
|
|
46
|
-
lon,
|
|
47
|
-
utypes
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Starts verification for a particular address using the response object returned by OkCollect
|
|
54
|
-
* @param {Object} response Response returned by OkCollect
|
|
55
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
56
|
-
*/
|
|
57
|
-
export const startVerification = (
|
|
58
|
-
response: OkCollectSuccessResponse
|
|
59
|
-
): Promise<string> => {
|
|
60
|
-
return new Promise(async (resolve, reject) => {
|
|
61
|
-
try {
|
|
62
|
-
const { location, user } = response;
|
|
63
|
-
if (!user.token || !user.id) {
|
|
64
|
-
throw new OkHiException({
|
|
65
|
-
code: OkHiException.UNAUTHORIZED_CODE,
|
|
66
|
-
message: OkHiException.UNAUTHORIZED_MESSAGE,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if (!location.id) {
|
|
70
|
-
throw new OkHiException({
|
|
71
|
-
code: OkHiException.BAD_REQUEST_CODE,
|
|
72
|
-
message: 'Missing location id from response',
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const usageTypes: UsageType = Array.isArray(response.location.usageTypes)
|
|
76
|
-
? response.location.usageTypes
|
|
77
|
-
: ['digital_verification'];
|
|
78
|
-
const result = await OkHiNativeModule.startAddressVerification(
|
|
79
|
-
user.token,
|
|
80
|
-
user.phone,
|
|
81
|
-
user.id,
|
|
82
|
-
location.id,
|
|
83
|
-
location.lat,
|
|
84
|
-
location.lon,
|
|
85
|
-
usageTypes
|
|
86
|
-
);
|
|
87
|
-
resolve(result);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
reject(error);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Stops verification for a particular address using a user's phonenumber and OkHi location identifier
|
|
96
|
-
* @param {string} phoneNumber The user's phone number
|
|
97
|
-
* @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.
|
|
98
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
99
|
-
*/
|
|
100
|
-
export const stopVerification = (phoneNumber: string, locationId: string) => {
|
|
101
|
-
return isValidPlatform(() =>
|
|
102
|
-
OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Android Only - Starts a foreground service that speeds up rate of verification
|
|
108
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
109
|
-
*/
|
|
110
|
-
export const startForegroundService = () => {
|
|
111
|
-
return isValidPlatform(
|
|
112
|
-
() => errorHandler(OkHiNativeModule.startForegroundService),
|
|
113
|
-
'android'
|
|
114
|
-
);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Android Only - Stops previously started foreground services
|
|
119
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully
|
|
120
|
-
*/
|
|
121
|
-
export const stopForegroundService = () => {
|
|
122
|
-
return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Android Only - Checks if the foreground service is running
|
|
127
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running
|
|
128
|
-
*/
|
|
129
|
-
export const isForegroundServiceRunning = () => {
|
|
130
|
-
return isValidPlatform(
|
|
131
|
-
OkHiNativeModule.isForegroundServiceRunning,
|
|
132
|
-
'android'
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Checks whether all necessary permissions and services are available in order to start the address verification process
|
|
138
|
-
* @param {Object} configuration Object that determines whether or not to request these permissions and services from the user
|
|
139
|
-
* @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user
|
|
140
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address verification process
|
|
141
|
-
*/
|
|
142
|
-
export const canStartVerification = (configuration?: {
|
|
143
|
-
requestServices?: boolean;
|
|
144
|
-
}): Promise<boolean> => {
|
|
145
|
-
return new Promise(async (resolve, reject) => {
|
|
146
|
-
const requestServices = configuration && configuration.requestServices;
|
|
147
|
-
const locationServicesStatus = await isLocationServicesEnabled();
|
|
148
|
-
const googlePlayServices =
|
|
149
|
-
Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;
|
|
150
|
-
const backgroundLocationPerm =
|
|
151
|
-
await isBackgroundLocationPermissionGranted();
|
|
152
|
-
const whenInUseLocationPerm = await isLocationPermissionGranted();
|
|
153
|
-
if (!requestServices) {
|
|
154
|
-
resolve(
|
|
155
|
-
locationServicesStatus && googlePlayServices && backgroundLocationPerm
|
|
156
|
-
);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
if (Platform.OS === 'ios') {
|
|
160
|
-
if (!locationServicesStatus) {
|
|
161
|
-
reject(
|
|
162
|
-
new OkHiException({
|
|
163
|
-
code: OkHiException.SERVICE_UNAVAILABLE_CODE,
|
|
164
|
-
message: 'Location services is unavailable',
|
|
165
|
-
})
|
|
166
|
-
);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (backgroundLocationPerm) {
|
|
170
|
-
resolve(true);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (whenInUseLocationPerm && !backgroundLocationPerm) {
|
|
174
|
-
resolve(false);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const iosPerm = await requestBackgroundLocationPermission();
|
|
178
|
-
resolve(iosPerm);
|
|
179
|
-
return;
|
|
180
|
-
} else if (Platform.OS === 'android') {
|
|
181
|
-
const locationServicesRequestStatus =
|
|
182
|
-
(await requestEnableLocationServices()) as boolean;
|
|
183
|
-
const gPlayServices = await requestEnableGooglePlayServices();
|
|
184
|
-
const androidPerm =
|
|
185
|
-
(await requestLocationPermission()) &&
|
|
186
|
-
(await requestBackgroundLocationPermission());
|
|
187
|
-
resolve(locationServicesRequestStatus && gPlayServices && androidPerm);
|
|
188
|
-
} else {
|
|
189
|
-
reject(
|
|
190
|
-
new OkHiException({
|
|
191
|
-
code: OkHiException.UNSUPPORTED_PLATFORM_CODE,
|
|
192
|
-
message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,
|
|
193
|
-
})
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Checks whether all necessary permissions and services are available in order to start the address verification process
|
|
201
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address verification process
|
|
202
|
-
*/
|
|
203
|
-
export const checkVerificationStartRequirements = (): Promise<boolean> => {
|
|
204
|
-
return new Promise(async (resolve, reject) => {
|
|
205
|
-
if (Platform.OS === 'android') {
|
|
206
|
-
const isPlayServicesAvailable = await isGooglePlayServicesAvailable();
|
|
207
|
-
if (!isPlayServicesAvailable) {
|
|
208
|
-
reject(
|
|
209
|
-
new OkHiException({
|
|
210
|
-
code: OkHiException.PLAY_SERVICES_UNAVAILABLE_CODE,
|
|
211
|
-
message: 'Google Play Services is unavailable',
|
|
212
|
-
})
|
|
213
|
-
);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (!(await isLocationServicesEnabled())) {
|
|
218
|
-
reject(
|
|
219
|
-
new OkHiException({
|
|
220
|
-
code: OkHiException.LOCATION_SERVICES_UNAVAILABLE_CODE,
|
|
221
|
-
message: 'Location services unavailable',
|
|
222
|
-
})
|
|
223
|
-
);
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
if (!(await isBackgroundLocationPermissionGranted())) {
|
|
227
|
-
reject(
|
|
228
|
-
new OkHiException({
|
|
229
|
-
code: OkHiException.PERMISSION_DENIED_CODE,
|
|
230
|
-
message: 'Background Location permission not granted',
|
|
231
|
-
})
|
|
232
|
-
);
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
resolve(true);
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Android Only - Updates user's device firebase push notification token
|
|
241
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
242
|
-
*/
|
|
243
|
-
export const onNewToken = (fcmPushNotificationToken: string) => {
|
|
244
|
-
if (Platform.OS === 'android') {
|
|
245
|
-
return OkHiNativeModule.onNewToken(fcmPushNotificationToken);
|
|
246
|
-
}
|
|
247
|
-
return Promise.resolve(true);
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Android Only - Should be invoked only when push notification is received.
|
|
252
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
253
|
-
*/
|
|
254
|
-
export const onMessageReceived = () => {
|
|
255
|
-
if (Platform.OS === 'android') {
|
|
256
|
-
return OkHiNativeModule.onMessageReceived();
|
|
257
|
-
}
|
|
258
|
-
return Promise.resolve(true);
|
|
259
|
-
};
|
package/src/OkVerify/types.ts
DELETED
|
File without changes
|
|
File without changes
|