react-native-okhi 1.0.10 → 1.0.11
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/.DS_Store +0 -0
- package/android/.project +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +18 -14
- package/lib/commonjs/OkCollect/OkHiLocationManager.js +7 -5
- package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +1 -1
- package/lib/commonjs/OkCollect/Util.js +1 -1
- package/lib/commonjs/OkCollect/app.json +1 -1
- package/lib/commonjs/OkCollect/index.js +4 -4
- package/lib/commonjs/OkCore/Helpers.js +1 -1
- package/lib/commonjs/OkCore/_helpers.js +1 -1
- package/lib/commonjs/OkCore/index.js +1 -1
- package/lib/commonjs/OkVerify/index.js +1 -3
- package/lib/commonjs/OkVerify/index.js.map +1 -1
- package/lib/module/OkCollect/OkHiLocationManager.js +7 -5
- package/lib/module/OkCollect/OkHiLocationManager.js.map +1 -1
- package/lib/module/OkCollect/app.json +1 -1
- package/lib/module/OkVerify/index.js +0 -2
- package/lib/module/OkVerify/index.js.map +1 -1
- package/package.json +1 -1
- package/react-native-okhi.podspec +1 -1
- package/src/OkCollect/app.json +1 -1
- package/src/OkVerify/index.ts +0 -1
package/android/.DS_Store
CHANGED
|
Binary file
|
package/android/.project
CHANGED
package/android/build.gradle
CHANGED
|
@@ -57,6 +57,6 @@ repositories {
|
|
|
57
57
|
dependencies {
|
|
58
58
|
//noinspection GradleDynamicVersion
|
|
59
59
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
60
|
-
implementation 'com.github.okhi:android-core:v1.3.
|
|
60
|
+
implementation 'com.github.okhi:android-core:v1.3.7'
|
|
61
61
|
implementation 'com.github.okhi:android-okverify:v1.4.6'
|
|
62
62
|
}
|
|
@@ -161,20 +161,24 @@ public class OkhiModule extends ReactContextBaseJavaModule {
|
|
|
161
161
|
String developer = config.getJSONObject("context").optString("developer", "external");
|
|
162
162
|
OkHiAppContext context = new OkHiAppContext(getReactApplicationContext(), mode, "react-native", developer);
|
|
163
163
|
auth = new OkHiAuth(getReactApplicationContext(), branchId, clientKey, context);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
164
|
+
if (getCurrentActivity() != null && getCurrentActivity().getApplicationContext() != null) {
|
|
165
|
+
okVerify = new OkVerify.Builder(getCurrentActivity(), auth).build();
|
|
166
|
+
if (config.has("notification")) {
|
|
167
|
+
JSONObject notificationConfig = config.getJSONObject("notification");
|
|
168
|
+
int importance = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? NotificationManager.IMPORTANCE_DEFAULT : 3;
|
|
169
|
+
OkVerify.init(getReactApplicationContext(), new OkHiNotification(
|
|
170
|
+
notificationConfig.optString("title", "Verification in progress"),
|
|
171
|
+
notificationConfig.optString("text", "Address Verification in progress"),
|
|
172
|
+
notificationConfig.optString("channelId", "okhi"),
|
|
173
|
+
notificationConfig.optString("channelName", "OkHi Channel"),
|
|
174
|
+
notificationConfig.optString("channelDescription", "OkHi verification alerts"),
|
|
175
|
+
importance
|
|
176
|
+
));
|
|
177
|
+
}
|
|
178
|
+
promise.resolve(true);
|
|
179
|
+
} else {
|
|
180
|
+
promise.resolve(false);
|
|
176
181
|
}
|
|
177
|
-
promise.resolve(true);
|
|
178
182
|
} catch (Exception e) {
|
|
179
183
|
e.printStackTrace();
|
|
180
184
|
promise.reject("unauthorized", "unable to parse credentials", e);
|
|
@@ -184,7 +188,7 @@ public class OkhiModule extends ReactContextBaseJavaModule {
|
|
|
184
188
|
@ReactMethod
|
|
185
189
|
public void startAddressVerification(String phoneNumber, String locationId, Float lat, Float lon, ReadableMap config, Promise promise) {
|
|
186
190
|
if (okVerify == null) {
|
|
187
|
-
promise.reject("unauthorized", "failed to initialise okhi
|
|
191
|
+
promise.reject("unauthorized", "failed to initialise okhi");
|
|
188
192
|
return;
|
|
189
193
|
}
|
|
190
194
|
OkHiUser user = new OkHiUser.Builder(phoneNumber).build();
|
|
@@ -55,11 +55,13 @@ const OkHiLocationManager = props => {
|
|
|
55
55
|
}
|
|
56
56
|
}, [onError, user.phone]);
|
|
57
57
|
|
|
58
|
-
const handleOnMessage =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
const handleOnMessage = _ref => {
|
|
59
|
+
let {
|
|
60
|
+
nativeEvent: {
|
|
61
|
+
data
|
|
62
|
+
}
|
|
63
|
+
} = _ref;
|
|
64
|
+
|
|
63
65
|
try {
|
|
64
66
|
const response = JSON.parse(data);
|
|
65
67
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["OkHiLocationManager.tsx"],"names":["OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","phone","auth","OkHiAuth","anonymousSignInWithPhoneNumber","then","catch","handleOnMessage","nativeEvent","data","response","JSON","parse","message","OkHiException","code","UNKNOWN_ERROR_CODE","payload","toString","location","startVerification","config","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","lat","lon","error","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","renderContent","jsAfterLoad","jsBeforeLoad","uri","Platform","OS","undefined"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AAEA;;AAEA;;;;;;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,GAAIC,KAAD,IAAqC;AACtE,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,qBAAwB,IAAxB,CAA1B;AACA,QAAM,CAACC,wBAAD,EAA2BC,2BAA3B,IACJ,qBAAuC,IAAvC,CADF;AAEA,QAAMC,YAAY,GAAG;AAAEC,IAAAA,IAAI,EAAE;AAAR,GAArB;AACA,QAAMC,KAAK,GAAGP,KAAK,CAACO,KAAN,GACV,EAAE,GAAGP,KAAK,CAACO,KAAX;AAAkB,OAAGF;AAArB,GADU,GAEVA,YAFJ;AAIA,QAAM;AAAEG,IAAAA,IAAF;AAAQC,IAAAA,SAAR;AAAmBC,IAAAA,cAAnB;AAAmCC,IAAAA,OAAnC;AAA4CC,IAAAA,MAA5C;AAAoDC,IAAAA;AAApD,MAA+Db,KAArE;AAEA,wBAAU,MAAM;AACd,QAAIQ,IAAI,CAACM,KAAT,EAAgB;AACd,YAAMC,IAAI,GAAG,IAAIC,kBAAJ,EAAb;AACAD,MAAAA,IAAI,CACDE,8BADH,CACkCT,IAAI,CAACM,KADvC,EAC8C,CAAC,SAAD,CAD9C,EAEGI,IAFH,CAEQhB,QAFR,EAGGiB,KAHH,CAGSR,OAHT;AAIA,iDACGO,IADH,CACQd,2BADR,EAEGe,KAFH,CAESR,OAFT;AAGD;AACF,GAXD,EAWG,CAACA,OAAD,EAAUH,IAAI,CAACM,KAAf,CAXH;;AAaA,QAAMM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"sources":["OkHiLocationManager.tsx"],"names":["OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","phone","auth","OkHiAuth","anonymousSignInWithPhoneNumber","then","catch","handleOnMessage","nativeEvent","data","response","JSON","parse","message","OkHiException","code","UNKNOWN_ERROR_CODE","payload","toString","location","startVerification","config","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","lat","lon","error","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","renderContent","jsAfterLoad","jsBeforeLoad","uri","Platform","OS","undefined"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AAEA;;AAEA;;;;;;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,GAAIC,KAAD,IAAqC;AACtE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GA,MAAM,GAAGoC,aAAa,EAAhB,GAAqB,IAD9B,CADF;AAKD,CA1HM;;;eA4HQlD,mB","sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Modal, SafeAreaView, Platform } from 'react-native';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport { Spinner } from './Spinner';\nimport type {\n OkHiLocationManagerResponse,\n OkHiLocationManagerProps,\n} from './types';\nimport {\n getFrameUrl,\n generateJavaScriptStartScript,\n generateStartDataPayload,\n parseOkHiLocation,\n} from './Util';\nimport { OkHiException } from '../OkCore/OkHiException';\nimport { OkHiAuth } from '../OkCore/OkHiAuth';\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { start as sv } from '../OkVerify';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\nimport { getApplicationConfiguration } from '../OkCore';\n/**\n * The OkHiLocationManager React Component is used to display an in app modal, enabling the user to quickly create an accurate OkHi address.\n */\nexport const OkHiLocationManager = (props: OkHiLocationManagerProps) => {\n const [token, setToken] = useState<string | null>(null);\n const [applicationConfiguration, setApplicationConfiguration] =\n useState<AuthApplicationConfig | null>(null);\n const defaultStyle = { flex: 1 };\n const style = props.style\n ? { ...props.style, ...defaultStyle }\n : defaultStyle;\n\n const { user, onSuccess, onCloseRequest, onError, loader, launch } = props;\n\n useEffect(() => {\n if (user.phone) {\n const auth = new OkHiAuth();\n auth\n .anonymousSignInWithPhoneNumber(user.phone, ['address'])\n .then(setToken)\n .catch(onError);\n getApplicationConfiguration()\n .then(setApplicationConfiguration)\n .catch(onError);\n }\n }, [onError, user.phone]);\n\n const handleOnMessage = ({ nativeEvent: { data } }: WebViewMessageEvent) => {\n try {\n const response: OkHiLocationManagerResponse = JSON.parse(data);\n if (response.message === 'fatal_exit') {\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: response.payload.toString(),\n })\n );\n } else if (response.message === 'exit_app') {\n onCloseRequest();\n } else {\n onSuccess({\n ...response.payload,\n location: parseOkHiLocation(response.payload.location),\n startVerification: function (config?: OkVerifyStartConfiguration) {\n const createdUser = { ...this.user };\n const location = { ...this.location };\n return new Promise((resolve, reject) => {\n if (!location.id) {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n } else {\n sv(\n createdUser.phone,\n location.id,\n location.lat,\n location.lon,\n config\n )\n .then(resolve)\n .catch(reject);\n }\n });\n },\n });\n }\n } catch (error) {\n let errorMessage = 'Something went wrong';\n if (error instanceof Error) {\n errorMessage = error.message;\n }\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: errorMessage,\n })\n );\n }\n };\n\n const handleOnError = () => {\n onError(\n new OkHiException({\n code: OkHiException.NETWORK_ERROR_CODE,\n message: OkHiException.NETWORK_ERROR_MESSAGE,\n })\n );\n };\n\n const renderContent = () => {\n if (token === null || applicationConfiguration == null) {\n return loader || <Spinner />;\n }\n\n const { jsAfterLoad, jsBeforeLoad } = generateJavaScriptStartScript({\n message: 'select_location',\n payload: generateStartDataPayload(props, token, applicationConfiguration),\n });\n\n return (\n <SafeAreaView style={style}>\n <WebView\n source={{ uri: getFrameUrl(applicationConfiguration) }}\n injectedJavaScriptBeforeContentLoaded={\n Platform.OS === 'ios' ? jsBeforeLoad : undefined\n }\n injectedJavaScript={Platform.OS === 'ios' ? undefined : jsAfterLoad}\n onMessage={handleOnMessage}\n onError={handleOnError}\n onHttpError={handleOnError}\n geolocationEnabled={true}\n allowsBackForwardNavigationGestures={true}\n />\n </SafeAreaView>\n );\n };\n\n return (\n <Modal animationType=\"slide\" transparent={false} visible={launch}>\n {launch ? renderContent() : null}\n </Modal>\n );\n};\n\nexport default OkHiLocationManager;\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.parseOkHiLocation = exports.
|
|
6
|
+
exports.parseOkHiLocation = exports.getFrameUrl = exports.generateStartDataPayload = exports.generateJavaScriptStartScript = void 0;
|
|
7
7
|
|
|
8
8
|
var _OkCore = require("../OkCore");
|
|
9
9
|
|
|
@@ -7,16 +7,16 @@ var _exportNames = {
|
|
|
7
7
|
OkHiLocationManagerProps: true,
|
|
8
8
|
OkCollectSuccessResponse: true
|
|
9
9
|
};
|
|
10
|
-
Object.defineProperty(exports, "
|
|
10
|
+
Object.defineProperty(exports, "OkCollectSuccessResponse", {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return _types.
|
|
13
|
+
return _types.OkCollectSuccessResponse;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
Object.defineProperty(exports, "
|
|
16
|
+
Object.defineProperty(exports, "OkHiLocationManagerProps", {
|
|
17
17
|
enumerable: true,
|
|
18
18
|
get: function () {
|
|
19
|
-
return _types.
|
|
19
|
+
return _types.OkHiLocationManagerProps;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.requestLocationPermission = exports.requestEnableLocationServices = exports.requestEnableGooglePlayServices = exports.requestBackgroundLocationPermission = exports.isLocationServicesEnabled = exports.isLocationPermissionGranted = exports.isGooglePlayServicesAvailable = exports.isBackgroundLocationPermissionGranted = exports.getSystemVersion = void 0;
|
|
7
7
|
|
|
8
8
|
var _OkHiNativeModule = require("../OkHiNativeModule");
|
|
9
9
|
|
|
@@ -7,8 +7,8 @@ var _exportNames = {
|
|
|
7
7
|
initialize: true,
|
|
8
8
|
getApplicationConfiguration: true
|
|
9
9
|
};
|
|
10
|
-
exports.initialize = initialize;
|
|
11
10
|
exports.getApplicationConfiguration = getApplicationConfiguration;
|
|
11
|
+
exports.initialize = initialize;
|
|
12
12
|
|
|
13
13
|
var _OkHiNativeModule = require("../OkHiNativeModule");
|
|
14
14
|
|
|
@@ -12,7 +12,7 @@ var _exportNames = {
|
|
|
12
12
|
isForegroundServiceRunning: true,
|
|
13
13
|
canStartVerification: true
|
|
14
14
|
};
|
|
15
|
-
exports.
|
|
15
|
+
exports.stopVerification = exports.stopForegroundService = exports.startVerification = exports.startForegroundService = exports.start = exports.isForegroundServiceRunning = exports.canStartVerification = void 0;
|
|
16
16
|
|
|
17
17
|
var _reactNative = require("react-native");
|
|
18
18
|
|
|
@@ -163,8 +163,6 @@ const canStartVerification = configuration => {
|
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
console.log('here..', requestServices);
|
|
167
|
-
|
|
168
166
|
if (!locationServicesStatus && _reactNative.Platform.OS === 'ios') {
|
|
169
167
|
reject(new _OkHiException.OkHiException({
|
|
170
168
|
code: _OkHiException.OkHiException.SERVICE_UNAVAILABLE_CODE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["start","phoneNumber","locationId","lat","lon","configuration","Platform","OS","OkHiNativeModule","startAddressVerification","startVerification","response","Promise","resolve","reject","location","user","id","result","phone","OkHiException","code","BAD_REQUEST_CODE","message","stopVerification","stopAddressVerification","startForegroundService","stopForegroundService","isForegroundServiceRunning","canStartVerification","requestServices","locationServicesStatus","googlePlayServices","backgroundLocationPerm","console","log","SERVICE_UNAVAILABLE_CODE","locationServicesRequestStatus","gPlayServices","perm"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;;AASA;;AACA;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,CACnBC,WADmB,EAEnBC,UAFmB,EAGnBC,GAHmB,EAInBC,GAJmB,EAKnBC,aALmB,KAMhB;AACH,SAAO,8BAAgB,MAAM;AAC3B,QAAIC,sBAASC,EA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A,MAAM,CACJ,IAAIM,4BAAJ,CAAkB;AAChBC,QAAAA,IAAI,EAAED,6BAAcgB,wBADJ;AAEhBb,QAAAA,OAAO,EAAE;AAFO,OAAlB,CADI,CAAN;AAMD,KAPD,MAOO;AACL,YAAMc,6BAA6B,GACjC/B,sBAASC,EAAT,KAAgB,KAAhB,GACI,IADJ,GAEM,MAAM,6CAHd;AAIA,YAAM+B,aAAa,GACjBhC,sBAASC,EAAT,KAAgB,KAAhB,GAAwB,IAAxB,GAA+B,MAAM,+CADvC;AAEA,UAAIgC,IAAI,GAAG,KAAX;;AACA,UAAIjC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBgC,QAAAA,IAAI,GAAG,MAAM,mDAAb;AACD,OAFD,MAEO;AACLA,QAAAA,IAAI,GACF,CAAC,MAAM,yCAAP,MACC,MAAM,mDADP,CADF;AAGD;;AACD1B,MAAAA,OAAO,CAACwB,6BAA6B,IAAIC,aAAjC,IAAkDC,IAAnD,CAAP;AACD;AACF,GAtCM,CAAP;AAuCD,CA1CM","sourcesContent":["import { Platform } from 'react-native';\nimport {\n isBackgroundLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n isLocationServicesEnabled,\n requestBackgroundLocationPermission,\n requestEnableGooglePlayServices,\n requestEnableLocationServices,\n requestLocationPermission,\n} from '../OkCore/Helpers';\nimport { errorHandler, isValidPlatform } from '../OkCore/_helpers';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkVerifyStartConfiguration } from './types';\nimport type { OkCollectSuccessResponse } from '../OkCollect/types';\nimport { OkHiException } from '../OkCore/OkHiException';\nexport * from './types';\n/**\n * Starts verification for a particular address\n * @param {string} phoneNumber A users phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @param {number} lat The latitude of the created address\n * @param {number} lon The longitude of the created address\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification, default is true\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const start = (\n phoneNumber: string,\n locationId: string,\n lat: number,\n lon: number,\n configuration?: OkVerifyStartConfiguration\n) => {\n return isValidPlatform(() => {\n if (Platform.OS === 'android') {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon,\n configuration\n );\n } else {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon\n );\n }\n });\n};\n\n/**\n * Starts verification for a particular address using the response object returned by OkCollect\n * @param {Object} response Response returned by OkCollect\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const startVerification = async (\n response: OkCollectSuccessResponse,\n configuration?: OkVerifyStartConfiguration\n) => {\n return new Promise((resolve, reject) => {\n const { location, user } = response;\n if (location.id) {\n if (Platform.OS === 'android') {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon,\n configuration\n );\n resolve(result);\n } else {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon\n );\n resolve(result);\n }\n } else {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n }\n });\n};\n\n/**\n * Stops verification for a particular address using a user's phonenumber and OkHi location identifier\n * @param {string} phoneNumber The user's phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const stopVerification = (phoneNumber: string, locationId: string) => {\n return isValidPlatform(() =>\n OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)\n );\n};\n\n/**\n * Android Only - Starts a foreground service that speeds up rate of verification\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const startForegroundService = () => {\n return isValidPlatform(\n () => errorHandler(OkHiNativeModule.startForegroundService),\n 'android'\n );\n};\n\n/**\n * Android Only - Stops previously started foreground services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully\n */\nexport const stopForegroundService = () => {\n return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');\n};\n\n/**\n * Android Only - Checks if the foreground service is running\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running\n */\nexport const isForegroundServiceRunning = () => {\n return isValidPlatform(\n OkHiNativeModule.isForegroundServiceRunning,\n 'android'\n );\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user\n * @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\n */\nexport const canStartVerification = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const backgroundLocationPerm =\n await isBackgroundLocationPermissionGranted();\n if (!requestServices) {\n resolve(\n locationServicesStatus && googlePlayServices && backgroundLocationPerm\n );\n return;\n }\n console.log('here..', requestServices);\n if (!locationServicesStatus && Platform.OS === 'ios') {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n } else {\n const locationServicesRequestStatus =\n Platform.OS === 'ios'\n ? true\n : ((await requestEnableLocationServices()) as boolean);\n const gPlayServices =\n Platform.OS === 'ios' ? true : await requestEnableGooglePlayServices();\n let perm = false;\n if (Platform.OS === 'ios') {\n perm = await requestBackgroundLocationPermission();\n } else {\n perm =\n (await requestLocationPermission()) &&\n (await requestBackgroundLocationPermission());\n }\n resolve(locationServicesRequestStatus && gPlayServices && perm);\n }\n });\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["start","phoneNumber","locationId","lat","lon","configuration","Platform","OS","OkHiNativeModule","startAddressVerification","startVerification","response","Promise","resolve","reject","location","user","id","result","phone","OkHiException","code","BAD_REQUEST_CODE","message","stopVerification","stopAddressVerification","startForegroundService","stopForegroundService","isForegroundServiceRunning","canStartVerification","requestServices","locationServicesStatus","googlePlayServices","backgroundLocationPerm","SERVICE_UNAVAILABLE_CODE","locationServicesRequestStatus","gPlayServices","perm"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;;AASA;;AACA;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG,CACnBC,WADmB,EAEnBC,UAFmB,EAGnBC,GAHmB,EAInBC,GAJmB,EAKnBC,aALmB,KAMhB;AACH,SAAO,8BAAgB,MAAM;AAC3B,QAAIC,sBAASC,EAAT,KAAgB,SAApB,EAA+B;AAC7B,aAAOC,mCAAiBC,wBAAjB,CACLR,WADK,EAELC,UAFK,EAGLC,GAHK,EAILC,GAJK,EAKLC,aALK,CAAP;AAOD,KARD,MAQO;AACL,aAAOG,mCAAiBC,wBAAjB,CACLR,WADK,EAELC,UAFK,EAGLC,GAHK,EAILC,GAJK,CAAP;AAMD;AACF,GAjBM,CAAP;AAkBD,CAzBM;AA2BP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMM,iBAAiB,GAAG,OAC/BC,QAD+B,EAE/BN,aAF+B,KAG5B;AACH,SAAO,IAAIO,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AACtC,UAAM;AAAEC,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAAqBL,QAA3B;;AACA,QAA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IC,aAAjC,IAAkDC,IAAnD,CAAP;AACD;AACF,GArCM,CAAP;AAsCD,CAzCM","sourcesContent":["import { Platform } from 'react-native';\nimport {\n isBackgroundLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n isLocationServicesEnabled,\n requestBackgroundLocationPermission,\n requestEnableGooglePlayServices,\n requestEnableLocationServices,\n requestLocationPermission,\n} from '../OkCore/Helpers';\nimport { errorHandler, isValidPlatform } from '../OkCore/_helpers';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkVerifyStartConfiguration } from './types';\nimport type { OkCollectSuccessResponse } from '../OkCollect/types';\nimport { OkHiException } from '../OkCore/OkHiException';\nexport * from './types';\n/**\n * Starts verification for a particular address\n * @param {string} phoneNumber A users phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @param {number} lat The latitude of the created address\n * @param {number} lon The longitude of the created address\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification, default is true\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const start = (\n phoneNumber: string,\n locationId: string,\n lat: number,\n lon: number,\n configuration?: OkVerifyStartConfiguration\n) => {\n return isValidPlatform(() => {\n if (Platform.OS === 'android') {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon,\n configuration\n );\n } else {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon\n );\n }\n });\n};\n\n/**\n * Starts verification for a particular address using the response object returned by OkCollect\n * @param {Object} response Response returned by OkCollect\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const startVerification = async (\n response: OkCollectSuccessResponse,\n configuration?: OkVerifyStartConfiguration\n) => {\n return new Promise((resolve, reject) => {\n const { location, user } = response;\n if (location.id) {\n if (Platform.OS === 'android') {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon,\n configuration\n );\n resolve(result);\n } else {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon\n );\n resolve(result);\n }\n } else {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n }\n });\n};\n\n/**\n * Stops verification for a particular address using a user's phonenumber and OkHi location identifier\n * @param {string} phoneNumber The user's phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const stopVerification = (phoneNumber: string, locationId: string) => {\n return isValidPlatform(() =>\n OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)\n );\n};\n\n/**\n * Android Only - Starts a foreground service that speeds up rate of verification\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const startForegroundService = () => {\n return isValidPlatform(\n () => errorHandler(OkHiNativeModule.startForegroundService),\n 'android'\n );\n};\n\n/**\n * Android Only - Stops previously started foreground services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully\n */\nexport const stopForegroundService = () => {\n return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');\n};\n\n/**\n * Android Only - Checks if the foreground service is running\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running\n */\nexport const isForegroundServiceRunning = () => {\n return isValidPlatform(\n OkHiNativeModule.isForegroundServiceRunning,\n 'android'\n );\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user\n * @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\n */\nexport const canStartVerification = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const backgroundLocationPerm =\n await isBackgroundLocationPermissionGranted();\n if (!requestServices) {\n resolve(\n locationServicesStatus && googlePlayServices && backgroundLocationPerm\n );\n return;\n }\n if (!locationServicesStatus && Platform.OS === 'ios') {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n } else {\n const locationServicesRequestStatus =\n Platform.OS === 'ios'\n ? true\n : ((await requestEnableLocationServices()) as boolean);\n const gPlayServices =\n Platform.OS === 'ios' ? true : await requestEnableGooglePlayServices();\n let perm = false;\n if (Platform.OS === 'ios') {\n perm = await requestBackgroundLocationPermission();\n } else {\n perm =\n (await requestLocationPermission()) &&\n (await requestBackgroundLocationPermission());\n }\n resolve(locationServicesRequestStatus && gPlayServices && perm);\n }\n });\n};\n"]}
|
|
@@ -36,11 +36,13 @@ export const OkHiLocationManager = props => {
|
|
|
36
36
|
}
|
|
37
37
|
}, [onError, user.phone]);
|
|
38
38
|
|
|
39
|
-
const handleOnMessage =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
const handleOnMessage = _ref => {
|
|
40
|
+
let {
|
|
41
|
+
nativeEvent: {
|
|
42
|
+
data
|
|
43
|
+
}
|
|
44
|
+
} = _ref;
|
|
45
|
+
|
|
44
46
|
try {
|
|
45
47
|
const response = JSON.parse(data);
|
|
46
48
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["OkHiLocationManager.tsx"],"names":["React","useState","useEffect","Modal","SafeAreaView","Platform","WebView","Spinner","getFrameUrl","generateJavaScriptStartScript","generateStartDataPayload","parseOkHiLocation","OkHiException","OkHiAuth","start","sv","getApplicationConfiguration","OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","phone","auth","anonymousSignInWithPhoneNumber","then","catch","handleOnMessage","nativeEvent","data","response","JSON","parse","message","code","UNKNOWN_ERROR_CODE","payload","toString","location","startVerification","config","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","lat","lon","error","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","renderContent","jsAfterLoad","jsBeforeLoad","uri","OS","undefined"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,SAASC,KAAT,EAAgBC,YAAhB,EAA8BC,QAA9B,QAA8C,cAA9C;AACA,SAASC,OAAT,QAA6C,sBAA7C;AACA,SAASC,OAAT,QAAwB,WAAxB;AAKA,SACEC,WADF,EAEEC,6BAFF,EAGEC,wBAHF,EAIEC,iBAJF,QAKO,QALP;AAMA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA,SAASC,KAAK,IAAIC,EAAlB,QAA4B,aAA5B;AAEA,SAASC,2BAAT,QAA4C,WAA5C;AACA;AACA;AACA;;AACA,OAAO,MAAMC,mBAAmB,GAAIC,KAAD,IAAqC;AACtE,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBnB,QAAQ,CAAgB,IAAhB,CAAlC;AACA,QAAM,CAACoB,wBAAD,EAA2BC,2BAA3B,IACJrB,QAAQ,CAA+B,IAA/B,CADV;AAEA,QAAMsB,YAAY,GAAG;AAAEC,IAAAA,IAAI,EAAE;AAAR,GAArB;AACA,QAAMC,KAAK,GAAGP,KAAK,CAACO,KAAN,GACV,EAAE,GAAGP,KAAK,CAACO,KAAX;AAAkB,OAAGF;AAArB,GADU,GAEVA,YAFJ;AAIA,QAAM;AAAEG,IAAAA,IAAF;AAAQC,IAAAA,SAAR;AAAmBC,IAAAA,cAAnB;AAAmCC,IAAAA,OAAnC;AAA4CC,IAAAA,MAA5C;AAAoDC,IAAAA;AAApD,MAA+Db,KAArE;AAEAhB,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIwB,IAAI,CAACM,KAAT,EAAgB;AACd,YAAMC,IAAI,GAAG,IAAIpB,QAAJ,EAAb;AACAoB,MAAAA,IAAI,CACDC,8BADH,CACkCR,IAAI,CAACM,KADvC,EAC8C,CAAC,SAAD,CAD9C,EAEGG,IAFH,CAEQf,QAFR,EAGGgB,KAHH,CAGSP,OAHT;AAIAb,MAAAA,2BAA2B,GACxBmB,IADH,CACQb,2BADR,EAEGc,KAFH,CAESP,OAFT;AAGD;AACF,GAXQ,EAWN,CAACA,OAAD,EAAUH,IAAI,CAACM,KAAf,CAXM,CAAT;;AAaA,QAAMK,eAAe,GAAG,
|
|
1
|
+
{"version":3,"sources":["OkHiLocationManager.tsx"],"names":["React","useState","useEffect","Modal","SafeAreaView","Platform","WebView","Spinner","getFrameUrl","generateJavaScriptStartScript","generateStartDataPayload","parseOkHiLocation","OkHiException","OkHiAuth","start","sv","getApplicationConfiguration","OkHiLocationManager","props","token","setToken","applicationConfiguration","setApplicationConfiguration","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","phone","auth","anonymousSignInWithPhoneNumber","then","catch","handleOnMessage","nativeEvent","data","response","JSON","parse","message","code","UNKNOWN_ERROR_CODE","payload","toString","location","startVerification","config","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","lat","lon","error","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","renderContent","jsAfterLoad","jsBeforeLoad","uri","OS","undefined"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,SAASC,KAAT,EAAgBC,YAAhB,EAA8BC,QAA9B,QAA8C,cAA9C;AACA,SAASC,OAAT,QAA6C,sBAA7C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QAAQ,CAACgE,EAAT,KAAgB,KAAhB,GAAwBF,YAAxB,GAAuCG,SAH3C;AAKE,MAAA,kBAAkB,EAAEjE,QAAQ,CAACgE,EAAT,KAAgB,KAAhB,GAAwBC,SAAxB,GAAoCJ,WAL1D;AAME,MAAA,SAAS,EAAE7B,eANb;AAOE,MAAA,OAAO,EAAEyB,aAPX;AAQE,MAAA,WAAW,EAAEA,aARf;AASE,MAAA,kBAAkB,EAAE,IATtB;AAUE,MAAA,mCAAmC,EAAE;AAVvC,MADF,CADF;AAgBD,GA1BD;;AA4BA,sBACE,oBAAC,KAAD;AAAO,IAAA,aAAa,EAAC,OAArB;AAA6B,IAAA,WAAW,EAAE,KAA1C;AAAiD,IAAA,OAAO,EAAE/B;AAA1D,KACGA,MAAM,GAAGkC,aAAa,EAAhB,GAAqB,IAD9B,CADF;AAKD,CA1HM;AA4HP,eAAehD,mBAAf","sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { Modal, SafeAreaView, Platform } from 'react-native';\nimport { WebView, WebViewMessageEvent } from 'react-native-webview';\nimport { Spinner } from './Spinner';\nimport type {\n OkHiLocationManagerResponse,\n OkHiLocationManagerProps,\n} from './types';\nimport {\n getFrameUrl,\n generateJavaScriptStartScript,\n generateStartDataPayload,\n parseOkHiLocation,\n} from './Util';\nimport { OkHiException } from '../OkCore/OkHiException';\nimport { OkHiAuth } from '../OkCore/OkHiAuth';\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { start as sv } from '../OkVerify';\nimport type { OkVerifyStartConfiguration } from '../OkVerify/types';\nimport { getApplicationConfiguration } from '../OkCore';\n/**\n * The OkHiLocationManager React Component is used to display an in app modal, enabling the user to quickly create an accurate OkHi address.\n */\nexport const OkHiLocationManager = (props: OkHiLocationManagerProps) => {\n const [token, setToken] = useState<string | null>(null);\n const [applicationConfiguration, setApplicationConfiguration] =\n useState<AuthApplicationConfig | null>(null);\n const defaultStyle = { flex: 1 };\n const style = props.style\n ? { ...props.style, ...defaultStyle }\n : defaultStyle;\n\n const { user, onSuccess, onCloseRequest, onError, loader, launch } = props;\n\n useEffect(() => {\n if (user.phone) {\n const auth = new OkHiAuth();\n auth\n .anonymousSignInWithPhoneNumber(user.phone, ['address'])\n .then(setToken)\n .catch(onError);\n getApplicationConfiguration()\n .then(setApplicationConfiguration)\n .catch(onError);\n }\n }, [onError, user.phone]);\n\n const handleOnMessage = ({ nativeEvent: { data } }: WebViewMessageEvent) => {\n try {\n const response: OkHiLocationManagerResponse = JSON.parse(data);\n if (response.message === 'fatal_exit') {\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: response.payload.toString(),\n })\n );\n } else if (response.message === 'exit_app') {\n onCloseRequest();\n } else {\n onSuccess({\n ...response.payload,\n location: parseOkHiLocation(response.payload.location),\n startVerification: function (config?: OkVerifyStartConfiguration) {\n const createdUser = { ...this.user };\n const location = { ...this.location };\n return new Promise((resolve, reject) => {\n if (!location.id) {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n } else {\n sv(\n createdUser.phone,\n location.id,\n location.lat,\n location.lon,\n config\n )\n .then(resolve)\n .catch(reject);\n }\n });\n },\n });\n }\n } catch (error) {\n let errorMessage = 'Something went wrong';\n if (error instanceof Error) {\n errorMessage = error.message;\n }\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: errorMessage,\n })\n );\n }\n };\n\n const handleOnError = () => {\n onError(\n new OkHiException({\n code: OkHiException.NETWORK_ERROR_CODE,\n message: OkHiException.NETWORK_ERROR_MESSAGE,\n })\n );\n };\n\n const renderContent = () => {\n if (token === null || applicationConfiguration == null) {\n return loader || <Spinner />;\n }\n\n const { jsAfterLoad, jsBeforeLoad } = generateJavaScriptStartScript({\n message: 'select_location',\n payload: generateStartDataPayload(props, token, applicationConfiguration),\n });\n\n return (\n <SafeAreaView style={style}>\n <WebView\n source={{ uri: getFrameUrl(applicationConfiguration) }}\n injectedJavaScriptBeforeContentLoaded={\n Platform.OS === 'ios' ? jsBeforeLoad : undefined\n }\n injectedJavaScript={Platform.OS === 'ios' ? undefined : jsAfterLoad}\n onMessage={handleOnMessage}\n onError={handleOnError}\n onHttpError={handleOnError}\n geolocationEnabled={true}\n allowsBackForwardNavigationGestures={true}\n />\n </SafeAreaView>\n );\n };\n\n return (\n <Modal animationType=\"slide\" transparent={false} visible={launch}>\n {launch ? renderContent() : null}\n </Modal>\n );\n};\n\nexport default OkHiLocationManager;\n"]}
|
|
@@ -110,8 +110,6 @@ export const canStartVerification = configuration => {
|
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
console.log('here..', requestServices);
|
|
114
|
-
|
|
115
113
|
if (!locationServicesStatus && Platform.OS === 'ios') {
|
|
116
114
|
reject(new OkHiException({
|
|
117
115
|
code: OkHiException.SERVICE_UNAVAILABLE_CODE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["Platform","isBackgroundLocationPermissionGranted","isGooglePlayServicesAvailable","isLocationServicesEnabled","requestBackgroundLocationPermission","requestEnableGooglePlayServices","requestEnableLocationServices","requestLocationPermission","errorHandler","isValidPlatform","OkHiNativeModule","OkHiException","start","phoneNumber","locationId","lat","lon","configuration","OS","startAddressVerification","startVerification","response","Promise","resolve","reject","location","user","id","result","phone","code","BAD_REQUEST_CODE","message","stopVerification","stopAddressVerification","startForegroundService","stopForegroundService","isForegroundServiceRunning","canStartVerification","requestServices","locationServicesStatus","googlePlayServices","backgroundLocationPerm","console","log","SERVICE_UNAVAILABLE_CODE","locationServicesRequestStatus","gPlayServices","perm"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AACA,SACEC,qCADF,EAEEC,6BAFF,EAGEC,yBAHF,EAIEC,mCAJF,EAKEC,+BALF,EAMEC,6BANF,EAOEC,yBAPF,QAQO,mBARP;AASA,SAASC,YAAT,EAAuBC,eAAvB,QAA8C,oBAA9C;AACA,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undLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n isLocationServicesEnabled,\n requestBackgroundLocationPermission,\n requestEnableGooglePlayServices,\n requestEnableLocationServices,\n requestLocationPermission,\n} from '../OkCore/Helpers';\nimport { errorHandler, isValidPlatform } from '../OkCore/_helpers';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkVerifyStartConfiguration } from './types';\nimport type { OkCollectSuccessResponse } from '../OkCollect/types';\nimport { OkHiException } from '../OkCore/OkHiException';\nexport * from './types';\n/**\n * Starts verification for a particular address\n * @param {string} phoneNumber A users phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @param {number} lat The latitude of the created address\n * @param {number} lon The longitude of the created address\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification, default is true\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const start = (\n phoneNumber: string,\n locationId: string,\n lat: number,\n lon: number,\n configuration?: OkVerifyStartConfiguration\n) => {\n return isValidPlatform(() => {\n if (Platform.OS === 'android') {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon,\n configuration\n );\n } else {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon\n );\n }\n });\n};\n\n/**\n * Starts verification for a particular address using the response object returned by OkCollect\n * @param {Object} response Response returned by OkCollect\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const startVerification = async (\n response: OkCollectSuccessResponse,\n configuration?: OkVerifyStartConfiguration\n) => {\n return new Promise((resolve, reject) => {\n const { location, user } = response;\n if (location.id) {\n if (Platform.OS === 'android') {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon,\n configuration\n );\n resolve(result);\n } else {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon\n );\n resolve(result);\n }\n } else {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n }\n });\n};\n\n/**\n * Stops verification for a particular address using a user's phonenumber and OkHi location identifier\n * @param {string} phoneNumber The user's phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const stopVerification = (phoneNumber: string, locationId: string) => {\n return isValidPlatform(() =>\n OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)\n );\n};\n\n/**\n * Android Only - Starts a foreground service that speeds up rate of verification\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const startForegroundService = () => {\n return isValidPlatform(\n () => errorHandler(OkHiNativeModule.startForegroundService),\n 'android'\n );\n};\n\n/**\n * Android Only - Stops previously started foreground services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully\n */\nexport const stopForegroundService = () => {\n return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');\n};\n\n/**\n * Android Only - Checks if the foreground service is running\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running\n */\nexport const isForegroundServiceRunning = () => {\n return isValidPlatform(\n OkHiNativeModule.isForegroundServiceRunning,\n 'android'\n );\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user\n * @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\n */\nexport const canStartVerification = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const backgroundLocationPerm =\n await isBackgroundLocationPermissionGranted();\n if (!requestServices) {\n resolve(\n locationServicesStatus && googlePlayServices && backgroundLocationPerm\n );\n return;\n }\n console.log('here..', requestServices);\n if (!locationServicesStatus && Platform.OS === 'ios') {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n } else {\n const locationServicesRequestStatus =\n Platform.OS === 'ios'\n ? true\n : ((await requestEnableLocationServices()) as boolean);\n const gPlayServices =\n Platform.OS === 'ios' ? true : await requestEnableGooglePlayServices();\n let perm = false;\n if (Platform.OS === 'ios') {\n perm = await requestBackgroundLocationPermission();\n } else {\n perm =\n (await requestLocationPermission()) &&\n (await requestBackgroundLocationPermission());\n }\n resolve(locationServicesRequestStatus && gPlayServices && perm);\n }\n });\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["Platform","isBackgroundLocationPermissionGranted","isGooglePlayServicesAvailable","isLocationServicesEnabled","requestBackgroundLocationPermission","requestEnableGooglePlayServices","requestEnableLocationServices","requestLocationPermission","errorHandler","isValidPlatform","OkHiNativeModule","OkHiException","start","phoneNumber","locationId","lat","lon","configuration","OS","startAddressVerification","startVerification","response","Promise","resolve","reject","location","user","id","result","phone","code","BAD_REQUEST_CODE","message","stopVerification","stopAddressVerification","startForegroundService","stopForegroundService","isForegroundServiceRunning","canStartVerification","requestServices","locationServicesStatus","googlePlayServices","backgroundLocationPerm","SERVICE_UNAVAILABLE_CODE","locationServicesRequestStatus","gPlayServices","perm"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AACA,SACEC,qCADF,EAEEC,6BAFF,EAGEC,yBAHF,EAIEC,mCAJF,EAKEC,+BALF,EAMEC,6BANF,EAOEC,yBAPF,QAQO,mBARP;AASA,SAASC,YAAT,EAAuBC,eAAv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;AACA,UAAMC,sBAAsB,GAAG,MAAMrC,yBAAyB,EAA9D;AACA,UAAMsC,kBAAkB,GACtBzC,QAAQ,CAACkB,EAAT,KAAgB,SAAhB,GAA4B,MAAMhB,6BAA6B,EAA/D,GAAoE,IADtE;AAEA,UAAMwC,sBAAsB,GAC1B,MAAMzC,qCAAqC,EAD7C;;AAEA,QAAI,CAACsC,eAAL,EAAsB;AACpBhB,MAAAA,OAAO,CACLiB,sBAAsB,IAAIC,kBAA1B,IAAgDC,sBAD3C,CAAP;AAGA;AACD;;AACD,QAAI,CAACF,sBAAD,IAA2BxC,QAAQ,CAACkB,EAAT,KAAgB,KAA/C,EAAsD;AACpDM,MAAAA,MAAM,CACJ,IAAIb,aAAJ,CAAkB;AAChBmB,QAAAA,IAAI,EAAEnB,aAAa,CAACgC,wBADJ;AAEhBX,QAAAA,OAAO,EAAE;AAFO,OAAlB,CADI,CAAN;AAMD,KAPD,MAOO;AACL,YAAMY,6BAA6B,GACjC5C,QAAQ,CAACkB,EAAT,KAAgB,KAAhB,GACI,IADJ,GAEM,MAAMZ,6BAA6B,EAH3C;AAIA,YAAMuC,aAAa,GACjB7C,QAAQ,CAACkB,EAAT,KAAgB,KAAhB,GAAwB,IAAxB,GAA+B,MAAMb,+BAA+B,EADtE;AAEA,UAAIyC,IAAI,GAAG,KAAX;;AACA,UAAI9C,QAAQ,CAACkB,EAAT,KAAgB,KAApB,EAA2B;AACzB4B,QAAAA,IAAI,GAAG,MAAM1C,mCAAmC,EAAhD;AACD,OAFD,MAEO;AACL0C,QAAAA,IAAI,GACF,CAAC,MAAMvC,yBAAyB,EAAhC,MACC,MAAMH,mCAAmC,EAD1C,CADF;AAGD;;AACDmB,MAAAA,OAAO,CAACqB,6BAA6B,IAAIC,aAAjC,IAAkDC,IAAnD,CAAP;AACD;AACF,GArCM,CAAP;AAsCD,CAzCM","sourcesContent":["import { Platform } from 'react-native';\nimport {\n isBackgroundLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n isLocationServicesEnabled,\n requestBackgroundLocationPermission,\n requestEnableGooglePlayServices,\n requestEnableLocationServices,\n requestLocationPermission,\n} from '../OkCore/Helpers';\nimport { errorHandler, isValidPlatform } from '../OkCore/_helpers';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkVerifyStartConfiguration } from './types';\nimport type { OkCollectSuccessResponse } from '../OkCollect/types';\nimport { OkHiException } from '../OkCore/OkHiException';\nexport * from './types';\n/**\n * Starts verification for a particular address\n * @param {string} phoneNumber A users phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @param {number} lat The latitude of the created address\n * @param {number} lon The longitude of the created address\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification, default is true\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const start = (\n phoneNumber: string,\n locationId: string,\n lat: number,\n lon: number,\n configuration?: OkVerifyStartConfiguration\n) => {\n return isValidPlatform(() => {\n if (Platform.OS === 'android') {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon,\n configuration\n );\n } else {\n return OkHiNativeModule.startAddressVerification(\n phoneNumber,\n locationId,\n lat,\n lon\n );\n }\n });\n};\n\n/**\n * Starts verification for a particular address using the response object returned by OkCollect\n * @param {Object} response Response returned by OkCollect\n * @param {Object} configuration Configures how verification will start on different platforms\n * @param {Object} configuration.android Specifices how verification will start on Android platforms\n * @param {boolean} configuration.android.withForeground Specifices if the foreground service will be turned on to speed up rate of verification\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const startVerification = async (\n response: OkCollectSuccessResponse,\n configuration?: OkVerifyStartConfiguration\n) => {\n return new Promise((resolve, reject) => {\n const { location, user } = response;\n if (location.id) {\n if (Platform.OS === 'android') {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon,\n configuration\n );\n resolve(result);\n } else {\n const result = OkHiNativeModule.startAddressVerification(\n user.phone,\n location.id,\n location.lat,\n location.lon\n );\n resolve(result);\n }\n } else {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n })\n );\n }\n });\n};\n\n/**\n * Stops verification for a particular address using a user's phonenumber and OkHi location identifier\n * @param {string} phoneNumber The user's phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const stopVerification = (phoneNumber: string, locationId: string) => {\n return isValidPlatform(() =>\n OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)\n );\n};\n\n/**\n * Android Only - Starts a foreground service that speeds up rate of verification\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const startForegroundService = () => {\n return isValidPlatform(\n () => errorHandler(OkHiNativeModule.startForegroundService),\n 'android'\n );\n};\n\n/**\n * Android Only - Stops previously started foreground services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully\n */\nexport const stopForegroundService = () => {\n return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');\n};\n\n/**\n * Android Only - Checks if the foreground service is running\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running\n */\nexport const isForegroundServiceRunning = () => {\n return isValidPlatform(\n OkHiNativeModule.isForegroundServiceRunning,\n 'android'\n );\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user\n * @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\n */\nexport const canStartVerification = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const backgroundLocationPerm =\n await isBackgroundLocationPermissionGranted();\n if (!requestServices) {\n resolve(\n locationServicesStatus && googlePlayServices && backgroundLocationPerm\n );\n return;\n }\n if (!locationServicesStatus && Platform.OS === 'ios') {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n } else {\n const locationServicesRequestStatus =\n Platform.OS === 'ios'\n ? true\n : ((await requestEnableLocationServices()) as boolean);\n const gPlayServices =\n Platform.OS === 'ios' ? true : await requestEnableGooglePlayServices();\n let perm = false;\n if (Platform.OS === 'ios') {\n perm = await requestBackgroundLocationPermission();\n } else {\n perm =\n (await requestLocationPermission()) &&\n (await requestBackgroundLocationPermission());\n }\n resolve(locationServicesRequestStatus && gPlayServices && perm);\n }\n });\n};\n"]}
|
package/package.json
CHANGED
package/src/OkCollect/app.json
CHANGED
package/src/OkVerify/index.ts
CHANGED