react-native-okhi 1.0.6 → 1.0.10
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/README.md +69 -31
- package/android/.DS_Store +0 -0
- package/android/build.gradle +1 -1
- package/ios/Okhi.swift +1 -0
- package/lib/commonjs/OkCollect/Helpers.js +4 -3
- package/lib/commonjs/OkCollect/Helpers.js.map +1 -1
- package/lib/commonjs/OkCollect/app.json +1 -1
- package/lib/commonjs/OkVerify/index.js +13 -4
- package/lib/commonjs/OkVerify/index.js.map +1 -1
- package/lib/module/OkCollect/Helpers.js +4 -3
- package/lib/module/OkCollect/Helpers.js.map +1 -1
- package/lib/module/OkCollect/app.json +1 -1
- package/lib/module/OkVerify/index.js +13 -4
- package/lib/module/OkVerify/index.js.map +1 -1
- package/package.json +1 -1
- package/src/OkCollect/Helpers.ts +6 -5
- package/src/OkCollect/app.json +1 -1
- package/src/OkVerify/index.ts +13 -13
- package/android/.gradle/6.6.1/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.6.1/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.6.1/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.6.1/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/configuration-cache/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# React Native
|
|
1
|
+
# OkHi React Native
|
|
2
2
|
|
|
3
3
|
The official OkHi React Native library will enable you to start collecting and verifying your user's addresses.
|
|
4
4
|
|
|
@@ -16,10 +16,7 @@ Use your sandbox keys while you test and develop, and your production mode keys
|
|
|
16
16
|
This library targets android devices >= SDK 23. Make sure you're targeting at-least the same by modifying your `android/build.gradle` file
|
|
17
17
|
|
|
18
18
|
```gradle
|
|
19
|
-
|
|
20
|
-
minSdkVersion = 23
|
|
21
|
-
..//
|
|
22
|
-
}
|
|
19
|
+
minSdkVersion = 23
|
|
23
20
|
```
|
|
24
21
|
|
|
25
22
|
### Add necessary permissions to your `AndroidManifest.xml`
|
|
@@ -39,7 +36,7 @@ ext {
|
|
|
39
36
|
</manifest>
|
|
40
37
|
```
|
|
41
38
|
|
|
42
|
-
If you're targeting Android versions
|
|
39
|
+
If you're targeting Android versions > 8 and you're using the OkVerify library you need to make sure your users select on "Allow always" when granting permissions otherwise the verification process won't work.
|
|
43
40
|
|
|
44
41
|
## iOS
|
|
45
42
|
|
|
@@ -49,6 +46,18 @@ OkHi obtains verification signals in the background, to enable this make sure to
|
|
|
49
46
|
|
|
50
47
|

|
|
51
48
|
|
|
49
|
+
### Change your deployment target
|
|
50
|
+
|
|
51
|
+
All OkHi React Native libraries target ios devices >= 12. Make sure you're targeting at-least the same by modifying your both your Podfile and deployment target in xcode.
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
Podile located under: `ios/Podfile`
|
|
56
|
+
|
|
57
|
+
```xml
|
|
58
|
+
platform :ios, '12.0'
|
|
59
|
+
```
|
|
60
|
+
|
|
52
61
|
### Add necessary permissions to your `Info.plist`
|
|
53
62
|
|
|
54
63
|
```xml
|
|
@@ -60,20 +69,25 @@ OkHi obtains verification signals in the background, to enable this make sure to
|
|
|
60
69
|
|
|
61
70
|
## Installation
|
|
62
71
|
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
Run the bellow command in the root directory of your React Native project.
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
yarn add react-native-okhi react-native-webview
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Finally install all required pods by running the following command in the ios directory
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
cd ios/ && pod install && cd ../
|
|
65
82
|
```
|
|
66
83
|
|
|
67
|
-
|
|
84
|
+
# Usage
|
|
68
85
|
|
|
69
|
-
|
|
86
|
+
## Initialization
|
|
70
87
|
|
|
71
|
-
Add the following
|
|
88
|
+
Add the following initialization code to your index.js file. Replace my_branch_id and my_client_key with the keys provided to you after sign up.
|
|
72
89
|
|
|
73
|
-
```
|
|
74
|
-
import { AppRegistry } from 'react-native';
|
|
75
|
-
import App from './src/App';
|
|
76
|
-
import { name as appName } from './app.json';
|
|
90
|
+
```javascript
|
|
77
91
|
import * as OkHi from 'react-native-okhi';
|
|
78
92
|
|
|
79
93
|
OkHi.initialize({
|
|
@@ -94,43 +108,67 @@ OkHi.initialize({
|
|
|
94
108
|
})
|
|
95
109
|
.then(() => console.log('init done'))
|
|
96
110
|
.catch(console.log);
|
|
97
|
-
|
|
98
|
-
AppRegistry.registerComponent(appName, () => App);
|
|
99
111
|
```
|
|
100
112
|
|
|
101
|
-
##
|
|
113
|
+
## Address Creation and Verification
|
|
102
114
|
|
|
103
|
-
```
|
|
104
|
-
import { useState } from 'react';
|
|
105
|
-
import { View } from 'react-native';
|
|
115
|
+
```javascript
|
|
116
|
+
import React, { useState, useEffect } from 'react';
|
|
117
|
+
import { View, Text } from 'react-native';
|
|
118
|
+
import { OkHiLocationManager, canStartVerification } from 'react-native-okhi';
|
|
106
119
|
|
|
107
120
|
const App = () => {
|
|
108
|
-
const [launch, setLaunch] = useState(
|
|
121
|
+
const [launch, setLaunch] = useState(false);
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
canStartVerification({ requestServices: true }).then((result) => {
|
|
125
|
+
setLaunch(result);
|
|
126
|
+
}); // checks & requests for required services for verification to run
|
|
127
|
+
});
|
|
128
|
+
|
|
109
129
|
const user = {
|
|
110
130
|
phone: '+254712345678', // required
|
|
111
131
|
firstName: 'Julius',
|
|
112
132
|
lastName: 'Kiano',
|
|
113
133
|
};
|
|
114
|
-
|
|
134
|
+
|
|
135
|
+
const handleOnSuccess = async (response) => {
|
|
115
136
|
console.log(response.user); // user information
|
|
116
137
|
console.log(response.location); // address information
|
|
117
138
|
await response.startVerification();
|
|
118
139
|
};
|
|
140
|
+
|
|
119
141
|
const handleOnError = (error) => {
|
|
120
142
|
console.log(error.code); // user information
|
|
121
143
|
console.log(error.message); // address information
|
|
122
144
|
setLaunch(false);
|
|
123
145
|
};
|
|
146
|
+
|
|
147
|
+
if (launch) {
|
|
148
|
+
return (
|
|
149
|
+
<View style={{ flex: 1 }}>
|
|
150
|
+
<OkHiLocationManager
|
|
151
|
+
user={user}
|
|
152
|
+
launch={launch}
|
|
153
|
+
onSuccess={handleOnSuccess}
|
|
154
|
+
onCloseRequest={() => setLaunch(false)} // called when user taps on the top right close button
|
|
155
|
+
onError={handleOnError}
|
|
156
|
+
/>
|
|
157
|
+
</View>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
124
161
|
return (
|
|
125
|
-
<View>
|
|
126
|
-
<
|
|
127
|
-
user={user}
|
|
128
|
-
launch={launch}
|
|
129
|
-
onSuccess={handleOnSuccess}
|
|
130
|
-
onCloseRequest={() => setLaunch(false)} // called when user taps on the top right close button
|
|
131
|
-
onError={handleOnError}
|
|
132
|
-
/>
|
|
162
|
+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
|
163
|
+
<Text>Loading..</Text>
|
|
133
164
|
</View>
|
|
134
165
|
);
|
|
135
166
|
};
|
|
167
|
+
|
|
168
|
+
export default App;
|
|
136
169
|
```
|
|
170
|
+
|
|
171
|
+
# Documentation
|
|
172
|
+
|
|
173
|
+
- [Guide](https://docs.okhi.co/v/v5.1-beta/okhi-on-your-react-native-app)
|
|
174
|
+
- [Best practices](https://docs.google.com/document/d/1kxolQJ4n6tEgReuqVLYpDVMW--xvqv5UQ7AdvrN0Uw0/edit)
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -58,5 +58,5 @@ dependencies {
|
|
|
58
58
|
//noinspection GradleDynamicVersion
|
|
59
59
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
60
60
|
implementation 'com.github.okhi:android-core:v1.3.4'
|
|
61
|
-
implementation 'com.github.okhi:android-okverify:v1.4.
|
|
61
|
+
implementation 'com.github.okhi:android-okverify:v1.4.6'
|
|
62
62
|
}
|
package/ios/Okhi.swift
CHANGED
|
@@ -49,6 +49,7 @@ class Okhi: NSObject {
|
|
|
49
49
|
okhiLocationService.delegate = self
|
|
50
50
|
self.resolve = resolve
|
|
51
51
|
locationPermissionRequestType = .whenInUse
|
|
52
|
+
okhiLocationService.requestLocationPermission(withBackgroundLocationPermission: false)
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
@objc func requestBackgroundLocationPermission(_ resolve:@escaping RCTPromiseResolveBlock, reject:RCTPromiseRejectBlock) {
|
|
@@ -26,6 +26,7 @@ const canStartAddressCreation = configuration => {
|
|
|
26
26
|
|
|
27
27
|
if (!requestServices) {
|
|
28
28
|
resolve(locationServicesStatus && googlePlayServices && locationPerm);
|
|
29
|
+
return;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
if (!locationServicesStatus && _reactNative.Platform.OS === 'ios') {
|
|
@@ -34,10 +35,10 @@ const canStartAddressCreation = configuration => {
|
|
|
34
35
|
message: 'Location services is unavailable'
|
|
35
36
|
}));
|
|
36
37
|
} else {
|
|
37
|
-
const locationServicesRequestStatus = await (0, _Helpers.requestEnableLocationServices)();
|
|
38
|
-
const
|
|
38
|
+
const locationServicesRequestStatus = _reactNative.Platform.OS === 'ios' ? true : await (0, _Helpers.requestEnableLocationServices)();
|
|
39
|
+
const gPlayServices = _reactNative.Platform.OS === 'android' ? await (0, _Helpers.requestEnableGooglePlayServices)() : true;
|
|
39
40
|
const locationPermStatus = await (0, _Helpers.requestLocationPermission)();
|
|
40
|
-
resolve(locationServicesRequestStatus &&
|
|
41
|
+
resolve(locationServicesRequestStatus && gPlayServices && locationPermStatus);
|
|
41
42
|
}
|
|
42
43
|
});
|
|
43
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Helpers.ts"],"names":["canStartAddressCreation","configuration","Promise","resolve","reject","requestServices","locationServicesStatus","googlePlayServices","Platform","OS","locationPerm","OkHiException","code","SERVICE_UNAVAILABLE_CODE","message","locationServicesRequestStatus","
|
|
1
|
+
{"version":3,"sources":["Helpers.ts"],"names":["canStartAddressCreation","configuration","Promise","resolve","reject","requestServices","locationServicesStatus","googlePlayServices","Platform","OS","locationPerm","OkHiException","code","SERVICE_UNAVAILABLE_CODE","message","locationServicesRequestStatus","gPlayServices","locationPermStatus"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAIC,aAAD,IAEf;AACtB,SAAO,IAAIC,OAAJ,CAAY,OAAOC,OAAP,EAAgBC,MAAhB,KAA2B;AAC5C,UAAMC,eAAe,GAAGJ,aAAa,IAAIA,aAAa,CAACI,eAAvD;AACA,UAAMC,sBAAsB,GAAG,MAAM,yCAArC;AACA,UAAMC,kBAAkB,GACtBC,sBAASC,EAAT,KAAgB,SAAhB,GAA4B,MAAM,6CAAlC,GAAoE,IADtE;AAEA,UAAMC,YAAY,GAAG,MAAM,2CAA3B;;AACA,QAAI,CAACL,eAAL,EAAsB;AACpBF,MAAAA,OAAO,CAACG,sBAAsB,IAAIC,kBAA1B,IAAgDG,YAAjD,CAAP;AACA;AACD;;AACD,QAAI,CAACJ,sBAAD,IAA2BE,sBAASC,EAAT,KAAgB,KAA/C,EAAsD;AACpDL,MAAAA,MAAM,CACJ,IAAIO,4BAAJ,CAAkB;AAChBC,QAAAA,IAAI,EAAED,6BAAcE,wBADJ;AAEhBC,QAAAA,OAAO,EAAE;AAFO,OAAlB,CADI,CAAN;AAMD,KAPD,MAOO;AACL,YAAMC,6BAA6B,GACjCP,sBAASC,EAAT,KAAgB,KAAhB,GACI,IADJ,GAEM,MAAM,6CAHd;AAIA,YAAMO,aAAa,GACjBR,sBAASC,EAAT,KAAgB,SAAhB,GACI,MAAM,+CADV,GAEI,IAHN;AAIA,YAAMQ,kBAAkB,GAAG,MAAM,yCAAjC;AACAd,MAAAA,OAAO,CACLY,6BAA6B,IAAIC,aAAjC,IAAkDC,kBAD7C,CAAP;AAGD;AACF,GA/BM,CAAP;AAgCD,CAnCM","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"]}
|
|
@@ -160,8 +160,11 @@ const canStartVerification = configuration => {
|
|
|
160
160
|
|
|
161
161
|
if (!requestServices) {
|
|
162
162
|
resolve(locationServicesStatus && googlePlayServices && backgroundLocationPerm);
|
|
163
|
+
return;
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
console.log('here..', requestServices);
|
|
167
|
+
|
|
165
168
|
if (!locationServicesStatus && _reactNative.Platform.OS === 'ios') {
|
|
166
169
|
reject(new _OkHiException.OkHiException({
|
|
167
170
|
code: _OkHiException.OkHiException.SERVICE_UNAVAILABLE_CODE,
|
|
@@ -169,10 +172,16 @@ const canStartVerification = configuration => {
|
|
|
169
172
|
}));
|
|
170
173
|
} else {
|
|
171
174
|
const locationServicesRequestStatus = _reactNative.Platform.OS === 'ios' ? true : await (0, _Helpers.requestEnableLocationServices)();
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
const gPlayServices = _reactNative.Platform.OS === 'ios' ? true : await (0, _Helpers.requestEnableGooglePlayServices)();
|
|
176
|
+
let perm = false;
|
|
177
|
+
|
|
178
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
179
|
+
perm = await (0, _Helpers.requestBackgroundLocationPermission)();
|
|
180
|
+
} else {
|
|
181
|
+
perm = (await (0, _Helpers.requestLocationPermission)()) && (await (0, _Helpers.requestBackgroundLocationPermission)());
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
resolve(locationServicesRequestStatus && gPlayServices && perm);
|
|
176
185
|
}
|
|
177
186
|
});
|
|
178
187
|
};
|
|
@@ -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","SERVICE_UNAVAILABLE_CODE","locationServicesRequestStatus","googlePlayServicesRequestStatus","whenInUseLocationRequestStatus","backgroundLocationRequestStatus"],"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,QAAII,QAAQ,CAACE,EAAb,EAAiB;AACf,UAAIX,sBAASC,EAAT,KAAgB,SAApB,EAA+B;AAC7B,cAAMW,MAAM,GAAGV,mCAAiBC,wBAAjB,CACbO,IAAI,CAACG,KADQ,EAEbJ,QAAQ,CAACE,EAFI,EAGbF,QAAQ,CAACZ,GAHI,EAIbY,QAAQ,CAACX,GAJI,EAKbC,aALa,CAAf;;AAOAQ,QAAAA,OAAO,CAACK,MAAD,CAAP;AACD,OATD,MASO;AACL,cAAMA,MAAM,GAAG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A,UAAMC,kBAAkB,GACtB1B,sBAASC,EAAT,KAAgB,SAAhB,GAA4B,MAAM,6CAAlC,GAAoE,IADtE;AAEA,UAAM0B,sBAAsB,GAC1B,MAAM,qDADR;;AAEA,QAAI,CAACH,eAAL,EAAsB;AACpBjB,MAAAA,OAAO,CACLkB,sBAAsB,IAAIC,kBAA1B,IAAgDC,sBAD3C,CAAP;AAGD;;AACD,QAAI,CAACF,sBAAD,IAA2BzB,sBAASC,EAAT,KAAgB,KAA/C,EAAsD;AACpDO,MAAAA,MAAM,CACJ,IAAIM,4BAAJ,CAAkB;AAChBC,QAAAA,IAAI,EAAED,6BAAcc,wBADJ;AAEhBX,QAAAA,OAAO,EAAE;AAFO,OAAlB,CADI,CAAN;AAMD,KAPD,MAOO;AACL,YAAMY,6BAA6B,GACjC7B,sBAASC,EAAT,KAAgB,KAAhB,GACI,IADJ,GAEM,MAAM,6CAHd;AAIA,YAAM6B,+BAA+B,GACnC9B,sBAASC,EAAT,KAAgB,SAAhB,GACI,MAAM,+CADV,GAEI,IAHN;AAIA,YAAM8B,8BAA8B,GAAG,MAAM,yCAA7C;AACA,YAAMC,+BAA+B,GACnC,MAAM,mDADR;AAEAzB,MAAAA,OAAO,CACLsB,6BAA6B,IAC3BC,+BADF,IAEEC,8BAFF,IAGEC,+BAJG,CAAP;AAMD;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 }\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 googlePlayServicesRequestStatus =\n Platform.OS === 'android'\n ? await requestEnableGooglePlayServices()\n : true;\n const whenInUseLocationRequestStatus = await requestLocationPermission();\n const backgroundLocationRequestStatus =\n await requestBackgroundLocationPermission();\n resolve(\n locationServicesRequestStatus &&\n googlePlayServicesRequestStatus &&\n whenInUseLocationRequestStatus &&\n backgroundLocationRequestStatus\n );\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","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,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;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AhB,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"]}
|
|
@@ -17,6 +17,7 @@ export const canStartAddressCreation = configuration => {
|
|
|
17
17
|
|
|
18
18
|
if (!requestServices) {
|
|
19
19
|
resolve(locationServicesStatus && googlePlayServices && locationPerm);
|
|
20
|
+
return;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
if (!locationServicesStatus && Platform.OS === 'ios') {
|
|
@@ -25,10 +26,10 @@ export const canStartAddressCreation = configuration => {
|
|
|
25
26
|
message: 'Location services is unavailable'
|
|
26
27
|
}));
|
|
27
28
|
} else {
|
|
28
|
-
const locationServicesRequestStatus = await requestEnableLocationServices();
|
|
29
|
-
const
|
|
29
|
+
const locationServicesRequestStatus = Platform.OS === 'ios' ? true : await requestEnableLocationServices();
|
|
30
|
+
const gPlayServices = Platform.OS === 'android' ? await requestEnableGooglePlayServices() : true;
|
|
30
31
|
const locationPermStatus = await requestLocationPermission();
|
|
31
|
-
resolve(locationServicesRequestStatus &&
|
|
32
|
+
resolve(locationServicesRequestStatus && gPlayServices && locationPermStatus);
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Helpers.ts"],"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","
|
|
1
|
+
{"version":3,"sources":["Helpers.ts"],"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"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB;AACA,SACEC,yBADF,EAEEC,2BAFF,EAGEC,6BAHF,EAIEC,6BAJF,EAKEC,+BALF,EAMEC,yBANF,QAOO,mBAPP;AAQA,SAASC,aAAT,QAA8B,yBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAIC,aAAD,IAEf;AACtB,SAAO,IAAIC,OAAJ,CAAY,OAAOC,OAAP,EAAgBC,MAAhB,KAA2B;AAC5C,UAAMC,eAAe,GAAGJ,aAAa,IAAIA,aAAa,CAACI,eAAvD;AACA,UAAMC,sBAAsB,GAAG,MAAMb,yBAAyB,EAA9D;AACA,UAAMc,kBAAkB,GACtBf,QAAQ,CAACgB,EAAT,KAAgB,SAAhB,GAA4B,MAAMb,6BAA6B,EAA/D,GAAoE,IADtE;AAEA,UAAMc,YAAY,GAAG,MAAMf,2BAA2B,EAAtD;;AACA,QAAI,CAACW,eAAL,EAAsB;AACpBF,MAAAA,OAAO,CAACG,sBAAsB,IAAIC,kBAA1B,IAAgDE,YAAjD,CAAP;AACA;AACD;;AACD,QAAI,CAACH,sBAAD,IAA2Bd,QAAQ,CAACgB,EAAT,KAAgB,KAA/C,EAAsD;AACpDJ,MAAAA,MAAM,CACJ,IAAIL,aAAJ,CAAkB;AAChBW,QAAAA,IAAI,EAAEX,aAAa,CAACY,wBADJ;AAEhBC,QAAAA,OAAO,EAAE;AAFO,OAAlB,CADI,CAAN;AAMD,KAPD,MAOO;AACL,YAAMC,6BAA6B,GACjCrB,QAAQ,CAACgB,EAAT,KAAgB,KAAhB,GACI,IADJ,GAEM,MAAMZ,6BAA6B,EAH3C;AAIA,YAAMkB,aAAa,GACjBtB,QAAQ,CAACgB,EAAT,KAAgB,SAAhB,GACI,MAAMX,+BAA+B,EADzC,GAEI,IAHN;AAIA,YAAMkB,kBAAkB,GAAG,MAAMjB,yBAAyB,EAA1D;AACAK,MAAAA,OAAO,CACLU,6BAA6B,IAAIC,aAAjC,IAAkDC,kBAD7C,CAAP;AAGD;AACF,GA/BM,CAAP;AAgCD,CAnCM","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"]}
|
|
@@ -107,8 +107,11 @@ export const canStartVerification = configuration => {
|
|
|
107
107
|
|
|
108
108
|
if (!requestServices) {
|
|
109
109
|
resolve(locationServicesStatus && googlePlayServices && backgroundLocationPerm);
|
|
110
|
+
return;
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
console.log('here..', requestServices);
|
|
114
|
+
|
|
112
115
|
if (!locationServicesStatus && Platform.OS === 'ios') {
|
|
113
116
|
reject(new OkHiException({
|
|
114
117
|
code: OkHiException.SERVICE_UNAVAILABLE_CODE,
|
|
@@ -116,10 +119,16 @@ export const canStartVerification = configuration => {
|
|
|
116
119
|
}));
|
|
117
120
|
} else {
|
|
118
121
|
const locationServicesRequestStatus = Platform.OS === 'ios' ? true : await requestEnableLocationServices();
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
const gPlayServices = Platform.OS === 'ios' ? true : await requestEnableGooglePlayServices();
|
|
123
|
+
let perm = false;
|
|
124
|
+
|
|
125
|
+
if (Platform.OS === 'ios') {
|
|
126
|
+
perm = await requestBackgroundLocationPermission();
|
|
127
|
+
} else {
|
|
128
|
+
perm = (await requestLocationPermission()) && (await requestBackgroundLocationPermission());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
resolve(locationServicesRequestStatus && gPlayServices && perm);
|
|
123
132
|
}
|
|
124
133
|
});
|
|
125
134
|
};
|
|
@@ -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","SERVICE_UNAVAILABLE_CODE","locationServicesRequestStatus","googlePlayServicesRequestStatus","whenInUseLocationRequestStatus","backgroundLocationRequestStatus"],"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,SAASC,gBAAT,QAAiC,qBAAjC;AAGA,SAASC,aAAT,QAA8B,yBAA9B;AACA,cAAc,SAAd;AACA;AAC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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;AAGD;;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,+BAA+B,GACnC7C,QAAQ,CAACkB,EAAT,KAAgB,SAAhB,GACI,MAAMb,+BAA+B,EADzC,GAEI,IAHN;AAIA,YAAMyC,8BAA8B,GAAG,MAAMvC,yBAAyB,EAAtE;AACA,YAAMwC,+BAA+B,GACnC,MAAM3C,mCAAmC,EAD3C;AAEAmB,MAAAA,OAAO,CACLqB,6BAA6B,IAC3BC,+BADF,IAEEC,8BAFF,IAGEC,+BAJG,CAAP;AAMD;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 }\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 googlePlayServicesRequestStatus =\n Platform.OS === 'android'\n ? await requestEnableGooglePlayServices()\n : true;\n const whenInUseLocationRequestStatus = await requestLocationPermission();\n const backgroundLocationRequestStatus =\n await requestBackgroundLocationPermission();\n resolve(\n locationServicesRequestStatus &&\n googlePlayServicesRequestStatus &&\n whenInUseLocationRequestStatus &&\n backgroundLocationRequestStatus\n );\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","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,SAASC,gBAAT,QAAiC,qBAAjC;AAGA,SAASC,aAAT,QAA8B,yBAA9B;AACA,cAAc,SAAd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,KAAK,GAAG,CACnBC,WADmB,EAEnBC,UAFmB,EAGnBC,GAHmB,EAInBC,GAJmB,EAKnBC,aALmB,KAMhB;A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O,CACLiB,sBAAsB,IAAIC,kBAA1B,IAAgDC,sBAD3C,CAAP;AAGA;AACD;;AACDC,IAAAA,OAAO,CAACC,GAAR,CAAY,QAAZ,EAAsBL,eAAtB;;AACA,QAAI,CAACC,sBAAD,IAA2BxC,QAAQ,CAACkB,EAAT,KAAgB,KAA/C,EAAsD;AACpDM,MAAAA,MAAM,CACJ,IAAIb,aAAJ,CAAkB;AAChBmB,QAAAA,IAAI,EAAEnB,aAAa,CAACkC,wBADJ;AAEhBb,QAAAA,OAAO,EAAE;AAFO,OAAlB,CADI,CAAN;AAMD,KAPD,MAOO;AACL,YAAMc,6BAA6B,GACjC9C,QAAQ,CAACkB,EAAT,KAAgB,KAAhB,GACI,IADJ,GAEM,MAAMZ,6BAA6B,EAH3C;AAIA,YAAMyC,aAAa,GACjB/C,QAAQ,CAACkB,EAAT,KAAgB,KAAhB,GAAwB,IAAxB,GAA+B,MAAMb,+BAA+B,EADtE;AAEA,UAAI2C,IAAI,GAAG,KAAX;;AACA,UAAIhD,QAAQ,CAACkB,EAAT,KAAgB,KAApB,EAA2B;AACzB8B,QAAAA,IAAI,GAAG,MAAM5C,mCAAmC,EAAhD;AACD,OAFD,MAEO;AACL4C,QAAAA,IAAI,GACF,CAAC,MAAMzC,yBAAyB,EAAhC,MACC,MAAMH,mCAAmC,EAD1C,CADF;AAGD;;AACDmB,MAAAA,OAAO,CAACuB,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"]}
|
package/package.json
CHANGED
package/src/OkCollect/Helpers.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const canStartAddressCreation = (configuration?: {
|
|
|
26
26
|
const locationPerm = await isLocationPermissionGranted();
|
|
27
27
|
if (!requestServices) {
|
|
28
28
|
resolve(locationServicesStatus && googlePlayServices && locationPerm);
|
|
29
|
+
return;
|
|
29
30
|
}
|
|
30
31
|
if (!locationServicesStatus && Platform.OS === 'ios') {
|
|
31
32
|
reject(
|
|
@@ -36,16 +37,16 @@ export const canStartAddressCreation = (configuration?: {
|
|
|
36
37
|
);
|
|
37
38
|
} else {
|
|
38
39
|
const locationServicesRequestStatus =
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
Platform.OS === 'ios'
|
|
41
|
+
? true
|
|
42
|
+
: ((await requestEnableLocationServices()) as boolean);
|
|
43
|
+
const gPlayServices =
|
|
41
44
|
Platform.OS === 'android'
|
|
42
45
|
? await requestEnableGooglePlayServices()
|
|
43
46
|
: true;
|
|
44
47
|
const locationPermStatus = await requestLocationPermission();
|
|
45
48
|
resolve(
|
|
46
|
-
locationServicesRequestStatus &&
|
|
47
|
-
googlePlayServicesRequestStatus &&
|
|
48
|
-
locationPermStatus
|
|
49
|
+
locationServicesRequestStatus && gPlayServices && locationPermStatus
|
|
49
50
|
);
|
|
50
51
|
}
|
|
51
52
|
});
|
package/src/OkCollect/app.json
CHANGED
package/src/OkVerify/index.ts
CHANGED
|
@@ -158,7 +158,9 @@ export const canStartVerification = (configuration?: {
|
|
|
158
158
|
resolve(
|
|
159
159
|
locationServicesStatus && googlePlayServices && backgroundLocationPerm
|
|
160
160
|
);
|
|
161
|
+
return;
|
|
161
162
|
}
|
|
163
|
+
console.log('here..', requestServices);
|
|
162
164
|
if (!locationServicesStatus && Platform.OS === 'ios') {
|
|
163
165
|
reject(
|
|
164
166
|
new OkHiException({
|
|
@@ -171,19 +173,17 @@ export const canStartVerification = (configuration?: {
|
|
|
171
173
|
Platform.OS === 'ios'
|
|
172
174
|
? true
|
|
173
175
|
: ((await requestEnableLocationServices()) as boolean);
|
|
174
|
-
const
|
|
175
|
-
Platform.OS === '
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
backgroundLocationRequestStatus
|
|
186
|
-
);
|
|
176
|
+
const gPlayServices =
|
|
177
|
+
Platform.OS === 'ios' ? true : await requestEnableGooglePlayServices();
|
|
178
|
+
let perm = false;
|
|
179
|
+
if (Platform.OS === 'ios') {
|
|
180
|
+
perm = await requestBackgroundLocationPermission();
|
|
181
|
+
} else {
|
|
182
|
+
perm =
|
|
183
|
+
(await requestLocationPermission()) &&
|
|
184
|
+
(await requestBackgroundLocationPermission());
|
|
185
|
+
}
|
|
186
|
+
resolve(locationServicesRequestStatus && gPlayServices && perm);
|
|
187
187
|
}
|
|
188
188
|
});
|
|
189
189
|
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|