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
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import { isLocationServicesEnabled, isLocationPermissionGranted, isGooglePlayServicesAvailable, requestEnableLocationServices, requestEnableGooglePlayServices, requestLocationPermission } from '../OkCore/Helpers';
|
|
3
|
-
import { OkHiException } from '../OkCore/OkHiException';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Checks whether all necessary permissions and services are available in order to start the address creation process.
|
|
7
|
-
* @param {Object} configuration Object that determines whether or not to request these permissions and services from the user.
|
|
8
|
-
* @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user.
|
|
9
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address creation process.
|
|
10
|
-
*/
|
|
11
|
-
export const canStartAddressCreation = configuration => {
|
|
12
|
-
return new Promise(async (resolve, reject) => {
|
|
13
|
-
const requestServices = configuration && configuration.requestServices;
|
|
14
|
-
const locationServicesStatus = await isLocationServicesEnabled();
|
|
15
|
-
const googlePlayServices = Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;
|
|
16
|
-
const locationPerm = await isLocationPermissionGranted();
|
|
17
|
-
if (!requestServices) {
|
|
18
|
-
resolve(locationServicesStatus && googlePlayServices && locationPerm);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!locationServicesStatus && Platform.OS === 'ios') {
|
|
22
|
-
reject(new OkHiException({
|
|
23
|
-
code: OkHiException.SERVICE_UNAVAILABLE_CODE,
|
|
24
|
-
message: 'Location services is unavailable'
|
|
25
|
-
}));
|
|
26
|
-
} else {
|
|
27
|
-
const locationServicesRequestStatus = Platform.OS === 'ios' ? true : await requestEnableLocationServices();
|
|
28
|
-
const gPlayServices = Platform.OS === 'android' ? await requestEnableGooglePlayServices() : true;
|
|
29
|
-
const locationPermStatus = await requestLocationPermission();
|
|
30
|
-
resolve(locationServicesRequestStatus && gPlayServices && locationPermStatus);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=Helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","isLocationServicesEnabled","isLocationPermissionGranted","isGooglePlayServicesAvailable","requestEnableLocationServices","requestEnableGooglePlayServices","requestLocationPermission","OkHiException","canStartAddressCreation","configuration","Promise","resolve","reject","requestServices","locationServicesStatus","googlePlayServices","OS","locationPerm","code","SERVICE_UNAVAILABLE_CODE","message","locationServicesRequestStatus","gPlayServices","locationPermStatus"],"sources":["Helpers.ts"],"sourcesContent":["import { Platform } from 'react-native';\nimport {\n isLocationServicesEnabled,\n isLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n requestEnableLocationServices,\n requestEnableGooglePlayServices,\n requestLocationPermission,\n} from '../OkCore/Helpers';\nimport { OkHiException } from '../OkCore/OkHiException';\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address creation 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 creation process.\n */\nexport const canStartAddressCreation = (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 locationPerm = await isLocationPermissionGranted();\n if (!requestServices) {\n resolve(locationServicesStatus && googlePlayServices && locationPerm);\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 === 'android'\n ? await requestEnableGooglePlayServices()\n : true;\n const locationPermStatus = await requestLocationPermission();\n resolve(\n locationServicesRequestStatus && gPlayServices && locationPermStatus\n );\n }\n });\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc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CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
-
import { Modal, SafeAreaView, Platform } from 'react-native';
|
|
3
|
-
import { WebView } from 'react-native-webview';
|
|
4
|
-
import { Spinner } from './Spinner';
|
|
5
|
-
import { getFrameUrl, generateJavaScriptStartScript, generateStartDataPayload, parseOkHiLocation, fetchCurrentLocation } from './Util';
|
|
6
|
-
import { OkHiException } from '../OkCore/OkHiException';
|
|
7
|
-
import { start as sv } from '../OkVerify';
|
|
8
|
-
import { getApplicationConfiguration, isBackgroundLocationPermissionGranted, isLocationPermissionGranted, openAppSettings, openProtectedAppsSettings, requestBackgroundLocationPermission, requestLocationPermission } from '../OkCore';
|
|
9
|
-
import { OkHiNativeModule } from '../OkHiNativeModule';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The OkHiLocationManager React Component is used to display an in app modal, enabling the user to quickly create an accurate OkHi address.
|
|
13
|
-
*/
|
|
14
|
-
export const OkHiLocationManager = props => {
|
|
15
|
-
const [applicationConfiguration, setApplicationConfiguration] = useState(null);
|
|
16
|
-
const [startPayload, setStartPaylaod] = useState(null);
|
|
17
|
-
const defaultStyle = {
|
|
18
|
-
flex: 1
|
|
19
|
-
};
|
|
20
|
-
const style = props.style ? {
|
|
21
|
-
...props.style,
|
|
22
|
-
...defaultStyle
|
|
23
|
-
} : defaultStyle;
|
|
24
|
-
const {
|
|
25
|
-
user,
|
|
26
|
-
onSuccess,
|
|
27
|
-
onCloseRequest,
|
|
28
|
-
onError,
|
|
29
|
-
loader,
|
|
30
|
-
launch
|
|
31
|
-
} = props;
|
|
32
|
-
const webViewRef = useRef(null);
|
|
33
|
-
const startMessage = props.mode === 'create' ? 'start_app' : 'select_location';
|
|
34
|
-
const [ready, setReady] = useState(false);
|
|
35
|
-
const androidAlwaysRequested = useRef(false);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (typeof launch === 'boolean') {
|
|
38
|
-
setReady(launch);
|
|
39
|
-
}
|
|
40
|
-
}, [launch]);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
async function startOkHiLocationManager() {
|
|
43
|
-
const appConfiguration = await getApplicationConfiguration();
|
|
44
|
-
if (!appConfiguration) {
|
|
45
|
-
throw new OkHiException({
|
|
46
|
-
code: OkHiException.UNAUTHORIZED_CODE,
|
|
47
|
-
message: OkHiException.UNAUTHORIZED_MESSAGE
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
const startPayload = await generateStartDataPayload(props, appConfiguration);
|
|
51
|
-
setApplicationConfiguration(appConfiguration);
|
|
52
|
-
setStartPaylaod(startPayload);
|
|
53
|
-
if (Platform.OS === 'android' && Platform.Version > 25) {
|
|
54
|
-
OkHiNativeModule.setItem('okcollect-launch-payload', JSON.stringify({
|
|
55
|
-
message: startMessage,
|
|
56
|
-
payload: startPayload,
|
|
57
|
-
url: getFrameUrl(appConfiguration)
|
|
58
|
-
})).catch(console.error);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (launch) {
|
|
62
|
-
startOkHiLocationManager();
|
|
63
|
-
}
|
|
64
|
-
}, [launch, props, onError]);
|
|
65
|
-
const runWebViewCallback = async result => {
|
|
66
|
-
var _webViewRef$current;
|
|
67
|
-
const level = await OkHiNativeModule.getLocationAccuracyLevel();
|
|
68
|
-
let callbackResult = result;
|
|
69
|
-
if ((result === 'blocked' || result === 'denied') && level === 'approximate') {
|
|
70
|
-
callbackResult = 'whenInUse';
|
|
71
|
-
}
|
|
72
|
-
const update = {
|
|
73
|
-
locationAccuracyLevel: level
|
|
74
|
-
};
|
|
75
|
-
const jsonUpdate = JSON.stringify(update).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
76
|
-
const jsString = `
|
|
77
|
-
(function (){
|
|
78
|
-
if (typeof runOkHiLocationManagerCallback === "function") {
|
|
79
|
-
runOkHiLocationManagerCallback("${callbackResult}", "${jsonUpdate}")
|
|
80
|
-
}
|
|
81
|
-
})()
|
|
82
|
-
`;
|
|
83
|
-
(_webViewRef$current = webViewRef.current) === null || _webViewRef$current === void 0 || _webViewRef$current.injectJavaScript(jsString);
|
|
84
|
-
};
|
|
85
|
-
const handleAndroidRequestLocationPermission = async level => {
|
|
86
|
-
try {
|
|
87
|
-
const _isLocationPermissionGranted = await isLocationPermissionGranted();
|
|
88
|
-
const _isBackgroundLocationPermissionGranted = await isBackgroundLocationPermissionGranted();
|
|
89
|
-
const _locationAccuracyLevel = await OkHiNativeModule.getLocationAccuracyLevel();
|
|
90
|
-
if (_isBackgroundLocationPermissionGranted && _locationAccuracyLevel === 'precise') {
|
|
91
|
-
runWebViewCallback('always');
|
|
92
|
-
} else if (level === 'whenInUse' && _isLocationPermissionGranted && _locationAccuracyLevel === 'precise') {
|
|
93
|
-
runWebViewCallback('whenInUse');
|
|
94
|
-
} else if (level === 'whenInUse' && _locationAccuracyLevel === 'no_permission') {
|
|
95
|
-
const result = await requestLocationPermission();
|
|
96
|
-
runWebViewCallback(result ? 'whenInUse' : 'denied');
|
|
97
|
-
} else if (level === 'always') {
|
|
98
|
-
const result = await requestBackgroundLocationPermission();
|
|
99
|
-
runWebViewCallback(result ? 'always' : 'denied');
|
|
100
|
-
androidAlwaysRequested.current = true;
|
|
101
|
-
} else if (level === 'whenInUse' && _locationAccuracyLevel === 'approximate') {
|
|
102
|
-
const result = await requestLocationPermission();
|
|
103
|
-
runWebViewCallback(result ? 'whenInUse' : 'denied');
|
|
104
|
-
} else {
|
|
105
|
-
openAppSettings();
|
|
106
|
-
}
|
|
107
|
-
} catch (error) {
|
|
108
|
-
onError(new OkHiException({
|
|
109
|
-
code: 'unknown',
|
|
110
|
-
message: 'could not request permission'
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const handleIOSRequestLocationPermission = async level => {
|
|
115
|
-
try {
|
|
116
|
-
const _isLocationPermissionGranted = await isLocationPermissionGranted();
|
|
117
|
-
const _isBackgroundLocationPermissionGranted = await isBackgroundLocationPermissionGranted();
|
|
118
|
-
const _locationAccuracyLevel = await OkHiNativeModule.getLocationAccuracyLevel();
|
|
119
|
-
if (_isBackgroundLocationPermissionGranted && _locationAccuracyLevel === 'precise') {
|
|
120
|
-
runWebViewCallback('always');
|
|
121
|
-
} else if (level === 'whenInUse' && _isLocationPermissionGranted && _locationAccuracyLevel === 'precise') {
|
|
122
|
-
runWebViewCallback('whenInUse');
|
|
123
|
-
} else if (level === 'whenInUse' && !_isLocationPermissionGranted) {
|
|
124
|
-
const result = await requestLocationPermission();
|
|
125
|
-
runWebViewCallback(result ? 'whenInUse' : 'denied');
|
|
126
|
-
} else {
|
|
127
|
-
openAppSettings();
|
|
128
|
-
}
|
|
129
|
-
} catch (error) {
|
|
130
|
-
onError(new OkHiException({
|
|
131
|
-
code: 'unknown',
|
|
132
|
-
message: 'could not request permission'
|
|
133
|
-
}));
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
const handleRequestLocationPermission = async ({
|
|
137
|
-
level
|
|
138
|
-
}) => {
|
|
139
|
-
if (Platform.OS === 'android') {
|
|
140
|
-
handleAndroidRequestLocationPermission(level);
|
|
141
|
-
} else if (Platform.OS === 'ios') {
|
|
142
|
-
handleIOSRequestLocationPermission(level);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const handleOpenAppSettings = async () => {
|
|
146
|
-
try {
|
|
147
|
-
const granted = await isBackgroundLocationPermissionGranted();
|
|
148
|
-
if (granted) {
|
|
149
|
-
runWebViewCallback('always');
|
|
150
|
-
} else {
|
|
151
|
-
await openAppSettings();
|
|
152
|
-
}
|
|
153
|
-
} catch (error) {
|
|
154
|
-
const err = error;
|
|
155
|
-
onError(err);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const handleFetchCurrentLocation = async () => {
|
|
159
|
-
try {
|
|
160
|
-
const location = await fetchCurrentLocation();
|
|
161
|
-
if (location) {
|
|
162
|
-
var _webViewRef$current2;
|
|
163
|
-
const jsString = `window.receiveCurrentLocation({lat: ${location.lat},lng: ${location.lng},accuracy: ${location.accuracy}})`;
|
|
164
|
-
(_webViewRef$current2 = webViewRef.current) === null || _webViewRef$current2 === void 0 || _webViewRef$current2.injectJavaScript(jsString);
|
|
165
|
-
}
|
|
166
|
-
} catch (error) {
|
|
167
|
-
console.error(error);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// prevents ios https... is requesting for your location
|
|
172
|
-
const handleWebViewOnLoad = () => {
|
|
173
|
-
if (Platform.OS === 'ios') {
|
|
174
|
-
var _webViewRef$current3;
|
|
175
|
-
const jsString = '(function(){navigator.geolocation.watchPosition=navigator.geolocation.getCurrentPosition=function(s,e,o){if(window.ReactNativeWebView&&typeof window.ReactNativeWebView.postMessage==="function"){window.ReactNativeWebView.postMessage(JSON.stringify({message:"fetch_current_location",payload:{}}));}window.receiveCurrentLocation=function(l){s({coords:{latitude:l.lat,longitude:l.lng,accuracy:l.accuracy,altitude:null,altitudeAccuracy:null,heading:null,speed:null},timestamp:Date.now()});};};})();';
|
|
176
|
-
(_webViewRef$current3 = webViewRef.current) === null || _webViewRef$current3 === void 0 || _webViewRef$current3.injectJavaScript(jsString);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
const handleOnMessage = ({
|
|
180
|
-
nativeEvent: {
|
|
181
|
-
data
|
|
182
|
-
}
|
|
183
|
-
}) => {
|
|
184
|
-
try {
|
|
185
|
-
const response = JSON.parse(data);
|
|
186
|
-
if (response.message === 'fatal_exit') {
|
|
187
|
-
//TODO: figure out bad phone number code
|
|
188
|
-
onError(new OkHiException({
|
|
189
|
-
code: OkHiException.UNKNOWN_ERROR_CODE,
|
|
190
|
-
message: response.payload
|
|
191
|
-
}));
|
|
192
|
-
} else if (response.message === 'exit_app') {
|
|
193
|
-
onCloseRequest();
|
|
194
|
-
} else if (response.message === 'request_enable_protected_apps') {
|
|
195
|
-
openProtectedAppsSettings();
|
|
196
|
-
} else if (response.message === 'location_created' || response.message === 'location_selected' || response.message === 'location_updated') {
|
|
197
|
-
setReady(false); // auto close
|
|
198
|
-
onSuccess({
|
|
199
|
-
user: {
|
|
200
|
-
...response.payload.user,
|
|
201
|
-
fcmPushNotificationToken: user.fcmPushNotificationToken
|
|
202
|
-
},
|
|
203
|
-
location: parseOkHiLocation(response.payload.location),
|
|
204
|
-
startVerification: function () {
|
|
205
|
-
const createdUser = {
|
|
206
|
-
...this.user
|
|
207
|
-
};
|
|
208
|
-
const location = {
|
|
209
|
-
...this.location
|
|
210
|
-
};
|
|
211
|
-
return new Promise((resolve, reject) => {
|
|
212
|
-
if (!location.id) {
|
|
213
|
-
reject(new OkHiException({
|
|
214
|
-
code: OkHiException.BAD_REQUEST_CODE,
|
|
215
|
-
message: 'Missing location id from response'
|
|
216
|
-
}));
|
|
217
|
-
} else if (!createdUser.id) {
|
|
218
|
-
reject(new OkHiException({
|
|
219
|
-
code: OkHiException.BAD_REQUEST_CODE,
|
|
220
|
-
message: 'Missing user id from response'
|
|
221
|
-
}));
|
|
222
|
-
} else if (!createdUser.token) {
|
|
223
|
-
reject(new OkHiException({
|
|
224
|
-
code: OkHiException.UNAUTHORIZED_CODE,
|
|
225
|
-
message: OkHiException.UNAUTHORIZED_MESSAGE
|
|
226
|
-
}));
|
|
227
|
-
} else {
|
|
228
|
-
const usageTypes = Array.isArray(location.usageTypes) ? location.usageTypes : ['digital_verification'];
|
|
229
|
-
sv(createdUser.token, createdUser.phone, createdUser.id, location.id, location.lat, location.lon, usageTypes).then(resolve).catch(reject);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
} else if (response.message === 'request_location_permission') {
|
|
235
|
-
handleRequestLocationPermission(response.payload);
|
|
236
|
-
} else if (response.message === 'open_app_settings') {
|
|
237
|
-
handleOpenAppSettings();
|
|
238
|
-
} else if (response.message === 'fetch_current_location') {
|
|
239
|
-
handleFetchCurrentLocation();
|
|
240
|
-
}
|
|
241
|
-
} catch (error) {
|
|
242
|
-
let errorMessage = 'Something went wrong';
|
|
243
|
-
if (error instanceof Error) {
|
|
244
|
-
errorMessage = error.message;
|
|
245
|
-
}
|
|
246
|
-
onError(new OkHiException({
|
|
247
|
-
code: OkHiException.UNKNOWN_ERROR_CODE,
|
|
248
|
-
message: errorMessage
|
|
249
|
-
}));
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
const handleOnError = () => {
|
|
253
|
-
onError(new OkHiException({
|
|
254
|
-
code: OkHiException.NETWORK_ERROR_CODE,
|
|
255
|
-
message: OkHiException.NETWORK_ERROR_MESSAGE
|
|
256
|
-
}));
|
|
257
|
-
};
|
|
258
|
-
const handleModalRequestClose = () => {
|
|
259
|
-
var _webViewRef$current4;
|
|
260
|
-
(_webViewRef$current4 = webViewRef.current) === null || _webViewRef$current4 === void 0 || _webViewRef$current4.goBack();
|
|
261
|
-
};
|
|
262
|
-
const renderContent = () => {
|
|
263
|
-
if (startPayload === null || applicationConfiguration == null) {
|
|
264
|
-
return loader || /*#__PURE__*/React.createElement(Spinner, null);
|
|
265
|
-
}
|
|
266
|
-
const {
|
|
267
|
-
jsAfterLoad,
|
|
268
|
-
jsBeforeLoad
|
|
269
|
-
} = generateJavaScriptStartScript({
|
|
270
|
-
message: startMessage,
|
|
271
|
-
payload: startPayload
|
|
272
|
-
});
|
|
273
|
-
return /*#__PURE__*/React.createElement(SafeAreaView, {
|
|
274
|
-
style: style
|
|
275
|
-
}, /*#__PURE__*/React.createElement(WebView, {
|
|
276
|
-
source: {
|
|
277
|
-
uri: getFrameUrl(applicationConfiguration)
|
|
278
|
-
},
|
|
279
|
-
injectedJavaScriptBeforeContentLoaded: Platform.OS === 'ios' ? jsBeforeLoad : undefined,
|
|
280
|
-
injectedJavaScript: Platform.OS === 'ios' ? undefined : jsAfterLoad,
|
|
281
|
-
onMessage: handleOnMessage,
|
|
282
|
-
onError: handleOnError,
|
|
283
|
-
onHttpError: handleOnError,
|
|
284
|
-
geolocationEnabled: true,
|
|
285
|
-
allowsBackForwardNavigationGestures: true,
|
|
286
|
-
onLoad: handleWebViewOnLoad,
|
|
287
|
-
ref: webViewRef
|
|
288
|
-
}));
|
|
289
|
-
};
|
|
290
|
-
return /*#__PURE__*/React.createElement(Modal, {
|
|
291
|
-
animationType: "slide",
|
|
292
|
-
transparent: false,
|
|
293
|
-
visible: ready,
|
|
294
|
-
onRequestClose: handleModalRequestClose
|
|
295
|
-
}, ready ? renderContent() : null);
|
|
296
|
-
};
|
|
297
|
-
export default OkHiLocationManager;
|
|
298
|
-
//# sourceMappingURL=OkHiLocationManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useState","useEffect","useRef","Modal","SafeAreaView","Platform","WebView","Spinner","getFrameUrl","generateJavaScriptStartScript","generateStartDataPayload","parseOkHiLocation","fetchCurrentLocation","OkHiException","start","sv","getApplicationConfiguration","isBackgroundLocationPermissionGranted","isLocationPermissionGranted","openAppSettings","openProtectedAppsSettings","requestBackgroundLocationPermission","requestLocationPermission","OkHiNativeModule","OkHiLocationManager","props","applicationConfiguration","setApplicationConfiguration","startPayload","setStartPaylaod","defaultStyle","flex","style","user","onSuccess","onCloseRequest","onError","loader","launch","webViewRef","startMessage","mode","ready","setReady","androidAlwaysRequested","startOkHiLocationManager","appConfiguration","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","OS","Version","setItem","JSON","stringify","payload","url","catch","console","error","runWebViewCallback","result","_webViewRef$current","level","getLocationAccuracyLevel","callbackResult","update","locationAccuracyLevel","jsonUpdate","replace","jsString","current","injectJavaScript","handleAndroidRequestLocationPermission","_isLocationPermissionGranted","_isBackgroundLocationPermissionGranted","_locationAccuracyLevel","handleIOSRequestLocationPermission","handleRequestLocationPermission","handleOpenAppSettings","granted","err","handleFetchCurrentLocation","location","_webViewRef$current2","lat","lng","accuracy","handleWebViewOnLoad","_webViewRef$current3","handleOnMessage","nativeEvent","data","response","parse","UNKNOWN_ERROR_CODE","fcmPushNotificationToken","startVerification","createdUser","Promise","resolve","reject","id","BAD_REQUEST_CODE","token","usageTypes","Array","isArray","phone","lon","then","errorMessage","Error","handleOnError","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","handleModalRequestClose","_webViewRef$current4","goBack","renderContent","createElement","jsAfterLoad","jsBeforeLoad","source","uri","injectedJavaScriptBeforeContentLoaded","undefined","injectedJavaScript","onMessage","onHttpError","geolocationEnabled","allowsBackForwardNavigationGestures","onLoad","ref","animationType","transparent","visible","onRequestClose"],"sources":["OkHiLocationManager.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } 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 OkHiLocationManagerStartDataPayload,\n} from './types';\nimport {\n getFrameUrl,\n generateJavaScriptStartScript,\n generateStartDataPayload,\n parseOkHiLocation,\n fetchCurrentLocation,\n} from './Util';\nimport { OkHiException } from '../OkCore/OkHiException';\nimport type { AuthApplicationConfig } from '../OkCore/_types';\nimport { start as sv } from '../OkVerify';\nimport {\n getApplicationConfiguration,\n isBackgroundLocationPermissionGranted,\n isLocationPermissionGranted,\n openAppSettings,\n openProtectedAppsSettings,\n requestBackgroundLocationPermission,\n requestLocationPermission,\n UsageType,\n} from '../OkCore';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\n\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 [applicationConfiguration, setApplicationConfiguration] =\n useState<AuthApplicationConfig | null>(null);\n const [startPayload, setStartPaylaod] =\n useState<null | OkHiLocationManagerStartDataPayload>(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 const webViewRef = useRef<WebView | null>(null);\n const startMessage =\n props.mode === 'create' ? 'start_app' : 'select_location';\n const [ready, setReady] = useState(false);\n const androidAlwaysRequested = useRef(false);\n\n useEffect(() => {\n if (typeof launch === 'boolean') {\n setReady(launch);\n }\n }, [launch]);\n\n useEffect(() => {\n async function startOkHiLocationManager() {\n const appConfiguration = await getApplicationConfiguration();\n if (!appConfiguration) {\n throw new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n }\n const startPayload = await generateStartDataPayload(\n props,\n appConfiguration\n );\n setApplicationConfiguration(appConfiguration);\n setStartPaylaod(startPayload);\n if (Platform.OS === 'android' && Platform.Version > 25) {\n OkHiNativeModule.setItem(\n 'okcollect-launch-payload',\n JSON.stringify({\n message: startMessage,\n payload: startPayload,\n url: getFrameUrl(appConfiguration),\n })\n ).catch(console.error);\n }\n }\n\n if (launch) {\n startOkHiLocationManager();\n }\n }, [launch, props, onError]);\n\n const runWebViewCallback = async (result: string) => {\n const level = await OkHiNativeModule.getLocationAccuracyLevel();\n let callbackResult = result;\n if (\n (result === 'blocked' || result === 'denied') &&\n level === 'approximate'\n ) {\n callbackResult = 'whenInUse';\n }\n const update = { locationAccuracyLevel: level };\n const jsonUpdate = JSON.stringify(update)\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"');\n const jsString = `\n (function (){\n if (typeof runOkHiLocationManagerCallback === \"function\") {\n runOkHiLocationManagerCallback(\"${callbackResult}\", \"${jsonUpdate}\")\n }\n })()\n `;\n webViewRef.current?.injectJavaScript(jsString);\n };\n\n const handleAndroidRequestLocationPermission = async (\n level: 'whenInUse' | 'always'\n ) => {\n try {\n const _isLocationPermissionGranted = await isLocationPermissionGranted();\n const _isBackgroundLocationPermissionGranted =\n await isBackgroundLocationPermissionGranted();\n const _locationAccuracyLevel =\n await OkHiNativeModule.getLocationAccuracyLevel();\n if (\n _isBackgroundLocationPermissionGranted &&\n _locationAccuracyLevel === 'precise'\n ) {\n runWebViewCallback('always');\n } else if (\n level === 'whenInUse' &&\n _isLocationPermissionGranted &&\n _locationAccuracyLevel === 'precise'\n ) {\n runWebViewCallback('whenInUse');\n } else if (\n level === 'whenInUse' &&\n _locationAccuracyLevel === 'no_permission'\n ) {\n const result = await requestLocationPermission();\n runWebViewCallback(result ? 'whenInUse' : 'denied');\n } else if (level === 'always') {\n const result = await requestBackgroundLocationPermission();\n runWebViewCallback(result ? 'always' : 'denied');\n androidAlwaysRequested.current = true;\n } else if (\n level === 'whenInUse' &&\n _locationAccuracyLevel === 'approximate'\n ) {\n const result = await requestLocationPermission();\n runWebViewCallback(result ? 'whenInUse' : 'denied');\n } else {\n openAppSettings();\n }\n } catch (error) {\n onError(\n new OkHiException({\n code: 'unknown',\n message: 'could not request permission',\n })\n );\n }\n };\n\n const handleIOSRequestLocationPermission = async (level: string) => {\n try {\n const _isLocationPermissionGranted = await isLocationPermissionGranted();\n const _isBackgroundLocationPermissionGranted =\n await isBackgroundLocationPermissionGranted();\n const _locationAccuracyLevel =\n await OkHiNativeModule.getLocationAccuracyLevel();\n\n if (\n _isBackgroundLocationPermissionGranted &&\n _locationAccuracyLevel === 'precise'\n ) {\n runWebViewCallback('always');\n } else if (\n level === 'whenInUse' &&\n _isLocationPermissionGranted &&\n _locationAccuracyLevel === 'precise'\n ) {\n runWebViewCallback('whenInUse');\n } else if (level === 'whenInUse' && !_isLocationPermissionGranted) {\n const result = await requestLocationPermission();\n runWebViewCallback(result ? 'whenInUse' : 'denied');\n } else {\n openAppSettings();\n }\n } catch (error) {\n onError(\n new OkHiException({\n code: 'unknown',\n message: 'could not request permission',\n })\n );\n }\n };\n\n const handleRequestLocationPermission = async ({\n level,\n }: {\n level: 'whenInUse' | 'always';\n }) => {\n if (Platform.OS === 'android') {\n handleAndroidRequestLocationPermission(level);\n } else if (Platform.OS === 'ios') {\n handleIOSRequestLocationPermission(level);\n }\n };\n\n const handleOpenAppSettings = async () => {\n try {\n const granted = await isBackgroundLocationPermissionGranted();\n if (granted) {\n runWebViewCallback('always');\n } else {\n await openAppSettings();\n }\n } catch (error) {\n const err = error as OkHiException;\n onError(err);\n }\n };\n\n const handleFetchCurrentLocation = async () => {\n try {\n const location = await fetchCurrentLocation();\n if (location) {\n const jsString = `window.receiveCurrentLocation({lat: ${location.lat},lng: ${location.lng},accuracy: ${location.accuracy}})`;\n webViewRef.current?.injectJavaScript(jsString);\n }\n } catch (error) {\n console.error(error);\n }\n };\n\n // prevents ios https... is requesting for your location\n const handleWebViewOnLoad = () => {\n if (Platform.OS === 'ios') {\n const jsString =\n '(function(){navigator.geolocation.watchPosition=navigator.geolocation.getCurrentPosition=function(s,e,o){if(window.ReactNativeWebView&&typeof window.ReactNativeWebView.postMessage===\"function\"){window.ReactNativeWebView.postMessage(JSON.stringify({message:\"fetch_current_location\",payload:{}}));}window.receiveCurrentLocation=function(l){s({coords:{latitude:l.lat,longitude:l.lng,accuracy:l.accuracy,altitude:null,altitudeAccuracy:null,heading:null,speed:null},timestamp:Date.now()});};};})();';\n webViewRef.current?.injectJavaScript(jsString);\n }\n };\n\n const handleOnMessage = ({ nativeEvent: { data } }: WebViewMessageEvent) => {\n try {\n const response: OkHiLocationManagerResponse = JSON.parse(data);\n if (response.message === 'fatal_exit') {\n //TODO: figure out bad phone number code\n onError(\n new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: response.payload,\n })\n );\n } else if (response.message === 'exit_app') {\n onCloseRequest();\n } else if (response.message === 'request_enable_protected_apps') {\n openProtectedAppsSettings();\n } else if (\n response.message === 'location_created' ||\n response.message === 'location_selected' ||\n response.message === 'location_updated'\n ) {\n setReady(false); // auto close\n onSuccess({\n user: {\n ...response.payload.user,\n fcmPushNotificationToken: user.fcmPushNotificationToken,\n },\n location: parseOkHiLocation(response.payload.location),\n startVerification: function () {\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 if (!createdUser.id) {\n reject(\n new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing user id from response',\n })\n );\n } else if (!createdUser.token) {\n reject(\n new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n })\n );\n } else {\n const usageTypes: UsageType = Array.isArray(location.usageTypes)\n ? location.usageTypes\n : ['digital_verification'];\n sv(\n createdUser.token,\n createdUser.phone,\n createdUser.id,\n location.id,\n location.lat,\n location.lon,\n usageTypes\n )\n .then(resolve)\n .catch(reject);\n }\n });\n },\n });\n } else if (response.message === 'request_location_permission') {\n handleRequestLocationPermission(response.payload);\n } else if (response.message === 'open_app_settings') {\n handleOpenAppSettings();\n } else if (response.message === 'fetch_current_location') {\n handleFetchCurrentLocation();\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 handleModalRequestClose = () => {\n webViewRef.current?.goBack();\n };\n\n const renderContent = () => {\n if (startPayload === null || applicationConfiguration == null) {\n return loader || <Spinner />;\n }\n\n const { jsAfterLoad, jsBeforeLoad } = generateJavaScriptStartScript({\n message: startMessage,\n payload: startPayload,\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 onLoad={handleWebViewOnLoad}\n ref={webViewRef}\n />\n </SafeAreaView>\n );\n };\n\n return (\n <Modal\n animationType=\"slide\"\n transparent={false}\n visible={ready}\n onRequestClose={handleModalRequestClose}\n >\n {ready ? renderContent() : null}\n </Modal>\n );\n};\n\nexport default OkHiLocationManager;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAC1D,SAASC,KAAK,EAAEC,YAAY,EAAEC,QAAQ,QAAQ,cAAc;AAC5D,SAASC,OAAO,QAA6B,sBAAsB;AACnE,SAASC,OAAO,QAAQ,WAAW;AAMnC,SACEC,WAAW,EACXC,6BAA6B,EAC7BC,wBAAwB,EACxBC,iBAAiB,EACjBC,oBAAoB,QACf,QAAQ;AACf,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,KAAK,IAAIC,EAAE,QAAQ,aAAa;AACzC,SACEC,2BAA2B,EAC3BC,qCAAqC,EACrCC,2BAA2B,EAC3BC,eAAe,EACfC,yBAAyB,EACzBC,mCAAmC,EACnCC,yBAAyB,QAEpB,WAAW;AAClB,SAASC,gBAAgB,QAAQ,qBAAqB;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAIC,KAA+B,IAAK;EACtE,MAAM,CAACC,wBAAwB,EAAEC,2BAA2B,CAAC,GAC3D3B,QAAQ,CAA+B,IAAI,CAAC;EAC9C,MAAM,CAAC4B,YAAY,EAAEC,eAAe,CAAC,GACnC7B,QAAQ,CAA6C,IAAI,CAAC;EAC5D,MAAM8B,YAAY,GAAG;IAAEC,IAAI,EAAE;EAAE,CAAC;EAChC,MAAMC,KAAK,GAAGP,KAAK,CAACO,KAAK,GACrB;IAAE,GAAGP,KAAK,CAACO,KAAK;IAAE,GAAGF;EAAa,CAAC,GACnCA,YAAY;EAEhB,MAAM;IAAEG,IAAI;IA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aAAA,CAACtH,KAAK;IACJoI,aAAa,EAAC,OAAO;IACrBC,WAAW,EAAE,KAAM;IACnBC,OAAO,EAAE/F,KAAM;IACfgG,cAAc,EAAErB;EAAwB,GAEvC3E,KAAK,GAAG8E,aAAa,CAAC,CAAC,GAAG,IACtB,CAAC;AAEZ,CAAC;AAED,eAAehG,mBAAmB","ignoreList":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ActivityIndicator, View } from 'react-native';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Default spinner component that'll be used as the initial loading indicator.
|
|
6
|
-
*/
|
|
7
|
-
export const Spinner = () => {
|
|
8
|
-
const style = {
|
|
9
|
-
flex: 1,
|
|
10
|
-
alignItems: 'center',
|
|
11
|
-
justifyContent: 'center'
|
|
12
|
-
};
|
|
13
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
14
|
-
style: style
|
|
15
|
-
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
16
|
-
color: "teal",
|
|
17
|
-
size: "small"
|
|
18
|
-
}));
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=Spinner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","ActivityIndicator","View","Spinner","style","flex","alignItems","justifyContent","createElement","color","size"],"sources":["Spinner.tsx"],"sourcesContent":["import React from 'react';\nimport { ActivityIndicator, View, ViewStyle } from 'react-native';\n\n/**\n * Default spinner component that'll be used as the initial loading indicator.\n */\nexport const Spinner = () => {\n const style: ViewStyle = {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n };\n return (\n <View style={style}>\n <ActivityIndicator color=\"teal\" size=\"small\" />\n </View>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,EAAEC,IAAI,QAAmB,cAAc;;AAEjE;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CAAA,KAAM;EAC3B,MAAMC,KAAgB,GAAG;IACvBC,IAAI,EAAE,CAAC;IACPC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACD,oBACEP,KAAA,CAAAQ,aAAA,CAACN,IAAI;IAACE,KAAK,EAAEA;EAAM,gBACjBJ,KAAA,CAAAQ,aAAA,CAACP,iBAAiB;IAACQ,KAAK,EAAC,MAAM;IAACC,IAAI,EAAC;EAAO,CAAE,CAC1C,CAAC;AAEX,CAAC","ignoreList":[]}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { canOpenProtectedAppsSettings, isBackgroundLocationPermissionGranted, isLocationPermissionGranted, OkHiException } from '../OkCore';
|
|
2
|
-
import { OkHiMode } from '../OkCore';
|
|
3
|
-
import manifest from './app.json'; //TODO: fix this
|
|
4
|
-
|
|
5
|
-
import { Platform } from 'react-native';
|
|
6
|
-
import { OkHiNativeModule } from '../OkHiNativeModule';
|
|
7
|
-
export const fetchCurrentLocation = async () => {
|
|
8
|
-
const result = await OkHiNativeModule.fetchCurrentLocation();
|
|
9
|
-
return result;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @ignore
|
|
14
|
-
*/
|
|
15
|
-
export const generateStartDataPayload = async (props, applicationConfiguration) => {
|
|
16
|
-
var _props$theme, _props$theme2, _applicationConfigura, _applicationConfigura2, _applicationConfigura3, _props$config, _props$theme3, _props$config2, _props$config3, _props$config4, _props$config5, _props$config6, _props$config7, _props$location;
|
|
17
|
-
const payload = {};
|
|
18
|
-
const {
|
|
19
|
-
manufacturer,
|
|
20
|
-
model,
|
|
21
|
-
osVersion,
|
|
22
|
-
platform
|
|
23
|
-
} = await OkHiNativeModule.retrieveDeviceInfo();
|
|
24
|
-
const geofences = await OkHiNativeModule.fetchRegisteredGeofences();
|
|
25
|
-
const locationAccuracyLevel = await OkHiNativeModule.getLocationAccuracyLevel();
|
|
26
|
-
if (geofences) {
|
|
27
|
-
payload.locations = JSON.parse(geofences);
|
|
28
|
-
}
|
|
29
|
-
payload.style = !props.theme ? undefined : {
|
|
30
|
-
base: {
|
|
31
|
-
color: (_props$theme = props.theme) === null || _props$theme === void 0 || (_props$theme = _props$theme.colors) === null || _props$theme === void 0 ? void 0 : _props$theme.primary,
|
|
32
|
-
logo: (_props$theme2 = props.theme) === null || _props$theme2 === void 0 || (_props$theme2 = _props$theme2.appBar) === null || _props$theme2 === void 0 ? void 0 : _props$theme2.logo,
|
|
33
|
-
name: (_applicationConfigura = applicationConfiguration.app) === null || _applicationConfigura === void 0 ? void 0 : _applicationConfigura.name
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
payload.user = {
|
|
37
|
-
phone: props.user.phone,
|
|
38
|
-
firstName: props.user.firstName,
|
|
39
|
-
lastName: props.user.lastName,
|
|
40
|
-
email: props.user.email,
|
|
41
|
-
appUserId: props.user.appUserId
|
|
42
|
-
};
|
|
43
|
-
payload.auth = {
|
|
44
|
-
branchId: applicationConfiguration.credentials.branchId,
|
|
45
|
-
clientKey: applicationConfiguration.credentials.clientKey
|
|
46
|
-
};
|
|
47
|
-
payload.context = {
|
|
48
|
-
container: {
|
|
49
|
-
name: (_applicationConfigura2 = applicationConfiguration.app) === null || _applicationConfigura2 === void 0 ? void 0 : _applicationConfigura2.name,
|
|
50
|
-
version: (_applicationConfigura3 = applicationConfiguration.app) === null || _applicationConfigura3 === void 0 ? void 0 : _applicationConfigura3.version
|
|
51
|
-
},
|
|
52
|
-
developer: {
|
|
53
|
-
name: applicationConfiguration.context.developer
|
|
54
|
-
},
|
|
55
|
-
library: {
|
|
56
|
-
name: manifest.name,
|
|
57
|
-
version: manifest.version
|
|
58
|
-
},
|
|
59
|
-
platform: {
|
|
60
|
-
name: 'react-native'
|
|
61
|
-
},
|
|
62
|
-
device: {
|
|
63
|
-
manufacturer,
|
|
64
|
-
model,
|
|
65
|
-
platform,
|
|
66
|
-
osVersion
|
|
67
|
-
},
|
|
68
|
-
locationAccuracyLevel
|
|
69
|
-
};
|
|
70
|
-
payload.config = {
|
|
71
|
-
streetView: typeof ((_props$config = props.config) === null || _props$config === void 0 ? void 0 : _props$config.streetView) === 'boolean' ? props.config.streetView : true,
|
|
72
|
-
appBar: {
|
|
73
|
-
color: (_props$theme3 = props.theme) === null || _props$theme3 === void 0 || (_props$theme3 = _props$theme3.appBar) === null || _props$theme3 === void 0 ? void 0 : _props$theme3.backgroundColor,
|
|
74
|
-
visible: (_props$config2 = props.config) === null || _props$config2 === void 0 || (_props$config2 = _props$config2.appBar) === null || _props$config2 === void 0 ? void 0 : _props$config2.visible
|
|
75
|
-
},
|
|
76
|
-
addressTypes: {
|
|
77
|
-
home: typeof ((_props$config3 = props.config) === null || _props$config3 === void 0 || (_props$config3 = _props$config3.addressTypes) === null || _props$config3 === void 0 ? void 0 : _props$config3.home) === 'boolean' ? (_props$config4 = props.config) === null || _props$config4 === void 0 || (_props$config4 = _props$config4.addressTypes) === null || _props$config4 === void 0 ? void 0 : _props$config4.home : true,
|
|
78
|
-
work: typeof ((_props$config5 = props.config) === null || _props$config5 === void 0 || (_props$config5 = _props$config5.addressTypes) === null || _props$config5 === void 0 ? void 0 : _props$config5.work) === 'boolean' ? (_props$config6 = props.config) === null || _props$config6 === void 0 || (_props$config6 = _props$config6.addressTypes) === null || _props$config6 === void 0 ? void 0 : _props$config6.work : true
|
|
79
|
-
},
|
|
80
|
-
protectedApps: Platform.OS === 'android' && (await canOpenProtectedAppsSettings()),
|
|
81
|
-
permissionsOnboarding: true,
|
|
82
|
-
usageTypes: ((_props$config7 = props.config) === null || _props$config7 === void 0 ? void 0 : _props$config7.usageTypes) || ['digital_verification']
|
|
83
|
-
};
|
|
84
|
-
if (Platform.OS === 'ios') {
|
|
85
|
-
const status = await OkHiNativeModule.fetchIOSLocationPermissionStatus();
|
|
86
|
-
const locationPermission = status === 'notDetermined' ? 'notDetermined' : status === 'authorizedWhenInUse' ? 'whenInUse' : status === 'authorizedAlways' ? 'always' : 'denied';
|
|
87
|
-
payload.context.permissions = {
|
|
88
|
-
location: locationPermission
|
|
89
|
-
};
|
|
90
|
-
if (status === 'authorized' || status === 'authorizedWhenInUse' || status === 'authorizedAlways') {
|
|
91
|
-
const location = await fetchCurrentLocation();
|
|
92
|
-
if (location) {
|
|
93
|
-
payload.context.coordinates = {
|
|
94
|
-
currentLocation: {
|
|
95
|
-
lat: location.lat,
|
|
96
|
-
lng: location.lng,
|
|
97
|
-
accuracy: location.accuracy
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
} else if (Platform.OS === 'android') {
|
|
103
|
-
let hasLocationPermission;
|
|
104
|
-
try {
|
|
105
|
-
hasLocationPermission = await isLocationPermissionGranted();
|
|
106
|
-
} catch (error) {
|
|
107
|
-
console.log(error);
|
|
108
|
-
}
|
|
109
|
-
let hasBackgroundLocationPermission;
|
|
110
|
-
try {
|
|
111
|
-
hasBackgroundLocationPermission = await isBackgroundLocationPermissionGranted();
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.log(error);
|
|
114
|
-
}
|
|
115
|
-
if (typeof hasLocationPermission === 'boolean' && typeof hasBackgroundLocationPermission === 'boolean') {
|
|
116
|
-
payload.context.permissions = {
|
|
117
|
-
location: hasBackgroundLocationPermission ? 'always' : hasLocationPermission ? 'whenInUse' : 'denied'
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
throw new OkHiException({
|
|
122
|
-
code: OkHiException.UNSUPPORTED_PLATFORM_CODE,
|
|
123
|
-
message: OkHiException.UNAUTHORIZED_MESSAGE
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
if ((_props$location = props.location) !== null && _props$location !== void 0 && _props$location.id) {
|
|
127
|
-
payload.location = {
|
|
128
|
-
id: props.location.id
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
return payload;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @ignore
|
|
136
|
-
*/
|
|
137
|
-
export const getFrameUrl = applicationConfiguration => {
|
|
138
|
-
const DEV_FRAME_URL = 'https://dev-manager-v5.okhi.io';
|
|
139
|
-
const PROD_FRAME_URL = 'https://manager-v5.okhi.io';
|
|
140
|
-
const SANDBOX_FRAME_URL = 'https://sandbox-manager-v5.okhi.io';
|
|
141
|
-
const LEGACY_DEV_FRAME_URL = 'https://dev-legacy-manager-v5.okhi.io';
|
|
142
|
-
const LEGACY_PROD_FRAME_URL = 'https://legacy-manager-v5.okhi.io';
|
|
143
|
-
const LEGACY_SANDBOX_FRAME_URL = 'https://sandbox-legacy-manager-v5.okhi.io';
|
|
144
|
-
if (Platform.OS === 'android' && Platform.Version < 24) {
|
|
145
|
-
if (applicationConfiguration.context.mode === OkHiMode.PROD) {
|
|
146
|
-
return LEGACY_PROD_FRAME_URL;
|
|
147
|
-
}
|
|
148
|
-
if (applicationConfiguration.context.mode === 'dev') {
|
|
149
|
-
return LEGACY_DEV_FRAME_URL;
|
|
150
|
-
}
|
|
151
|
-
return LEGACY_SANDBOX_FRAME_URL;
|
|
152
|
-
}
|
|
153
|
-
if (applicationConfiguration.context.mode === OkHiMode.PROD) {
|
|
154
|
-
return PROD_FRAME_URL;
|
|
155
|
-
}
|
|
156
|
-
if (applicationConfiguration.context.mode === 'dev') {
|
|
157
|
-
return DEV_FRAME_URL;
|
|
158
|
-
}
|
|
159
|
-
return SANDBOX_FRAME_URL;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* @ignore
|
|
164
|
-
*/
|
|
165
|
-
export const generateJavaScriptStartScript = startPayload => {
|
|
166
|
-
const jsBeforeLoad = `
|
|
167
|
-
window.isNativeApp = true;
|
|
168
|
-
window.NativeApp = {
|
|
169
|
-
bridge: {
|
|
170
|
-
receiveMessage: window.ReactNativeWebView.postMessage
|
|
171
|
-
},
|
|
172
|
-
data: ${JSON.stringify(startPayload)}
|
|
173
|
-
}
|
|
174
|
-
true;
|
|
175
|
-
`;
|
|
176
|
-
const jsAfterLoad = `window.startOkHiLocationManager({ receiveMessage: function(data) { window.ReactNativeWebView.postMessage(data) } }, ${JSON.stringify(startPayload)})`;
|
|
177
|
-
return {
|
|
178
|
-
jsBeforeLoad,
|
|
179
|
-
jsAfterLoad
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @ignore
|
|
185
|
-
*/
|
|
186
|
-
export const parseOkHiLocation = location => {
|
|
187
|
-
var _location$geo_point, _location$geo_point2, _location$street_view, _location$street_view2;
|
|
188
|
-
return {
|
|
189
|
-
id: location === null || location === void 0 ? void 0 : location.id,
|
|
190
|
-
lat: location === null || location === void 0 || (_location$geo_point = location.geo_point) === null || _location$geo_point === void 0 ? void 0 : _location$geo_point.lat,
|
|
191
|
-
lon: location === null || location === void 0 || (_location$geo_point2 = location.geo_point) === null || _location$geo_point2 === void 0 ? void 0 : _location$geo_point2.lon,
|
|
192
|
-
placeId: location === null || location === void 0 ? void 0 : location.place_id,
|
|
193
|
-
plusCode: location === null || location === void 0 ? void 0 : location.plus_code,
|
|
194
|
-
propertyName: location === null || location === void 0 ? void 0 : location.property_name,
|
|
195
|
-
streetName: location === null || location === void 0 ? void 0 : location.street_name,
|
|
196
|
-
title: location === null || location === void 0 ? void 0 : location.title,
|
|
197
|
-
subtitle: location === null || location === void 0 ? void 0 : location.subtitle,
|
|
198
|
-
directions: location === null || location === void 0 ? void 0 : location.directions,
|
|
199
|
-
otherInformation: location === null || location === void 0 ? void 0 : location.other_information,
|
|
200
|
-
url: location === null || location === void 0 ? void 0 : location.url,
|
|
201
|
-
streetViewPanoId: location === null || location === void 0 || (_location$street_view = location.street_view) === null || _location$street_view === void 0 ? void 0 : _location$street_view.pano_id,
|
|
202
|
-
streetViewPanoUrl: location === null || location === void 0 || (_location$street_view2 = location.street_view) === null || _location$street_view2 === void 0 ? void 0 : _location$street_view2.url,
|
|
203
|
-
userId: location === null || location === void 0 ? void 0 : location.user_id,
|
|
204
|
-
propertyNumber: location === null || location === void 0 ? void 0 : location.propertyNumber,
|
|
205
|
-
photo: location === null || location === void 0 ? void 0 : location.photo,
|
|
206
|
-
displayTitle: location === null || location === void 0 ? void 0 : location.display_title,
|
|
207
|
-
country: location === null || location === void 0 ? void 0 : location.country,
|
|
208
|
-
state: location === null || location === void 0 ? void 0 : location.state,
|
|
209
|
-
city: location === null || location === void 0 ? void 0 : location.city,
|
|
210
|
-
countryCode: location === null || location === void 0 ? void 0 : location.country_code,
|
|
211
|
-
usageTypes: location === null || location === void 0 ? void 0 : location.usage_types
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
//# sourceMappingURL=Util.js.map
|