react-native-okhi 1.2.32-beta.6 → 2.0.0-beta.1

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 CHANGED
@@ -1,37 +1,177 @@
1
+ <div align="left">
2
+
1
3
  # react-native-okhi
2
4
 
3
- The OkHi React Native library enables you to collect and verify addresses from your users
5
+ [![npm version](https://img.shields.io/npm/v/react-native-okhi.svg?style=flat-square)](https://www.npmjs.com/package/react-native-okhi)
6
+ [![license](https://img.shields.io/npm/l/react-native-okhi.svg?style=flat-square)](https://github.com/OkHi/react-native-okhi/blob/master/LICENSE)
7
+ [![platform](https://img.shields.io/badge/platform-iOS%20%7C%20Android-lightgrey?style=flat-square)](#requirements)
8
+ [![CI](https://img.shields.io/github/actions/workflow/status/OkHi/react-native-okhi/ci.yml?style=flat-square)](https://github.com/OkHi/react-native-okhi/actions/workflows/ci.yml)
9
+
10
+ </div>
4
11
 
5
- ## Installation
12
+ ## Quick Start
6
13
 
14
+ ### 1. Install
7
15
 
8
- ```sh
16
+ ```bash
9
17
  npm install react-native-okhi
18
+ # or
19
+ yarn add react-native-okhi
10
20
  ```
11
21
 
22
+ ### 2. Configure native projects
12
23
 
13
- ## Usage
24
+ <details>
25
+ <summary><b>iOS Setup</b></summary>
14
26
 
27
+ Install pods:
15
28
 
16
- ```js
17
- import { multiply } from 'react-native-okhi';
29
+ ```bash
30
+ cd ios && pod install && cd ..
31
+ ```
18
32
 
19
- // ...
33
+ Add to `Info.plist`:
20
34
 
21
- const result = multiply(3, 7);
35
+ ```xml
36
+ <key>NSLocationWhenInUseUsageDescription</key>
37
+ <string>Grant to enable creating addresses at your current location.</string>
38
+ <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
39
+ <string>Grant to enable creating and verifying your addresses.</string>
22
40
  ```
23
41
 
42
+ Enable Background Modes in Xcode → Signing & Capabilities:
24
43
 
25
- ## Contributing
44
+ - ✅ Location updates
45
+ - ✅ Background fetch
26
46
 
27
- - [Development workflow](CONTRIBUTING.md#development-workflow)
28
- - [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
29
- - [Code of conduct](CODE_OF_CONDUCT.md)
47
+ Add to `AppDelegate.mm`:
30
48
 
31
- ## License
49
+ ```objc
50
+ @import OkHi;
51
+
52
+ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
53
+ {
54
+ [OK startMonitoring];
55
+ // ... rest of your code
56
+ }
57
+ ```
58
+
59
+ If using swift `AppDelegate.swift`:
60
+
61
+ ```swift
62
+ import OkHi
32
63
 
33
- MIT
64
+ @main
65
+ class AppDelegate: UIResponder, UIApplicationDelegate {
34
66
 
35
- ---
67
+ func application(
68
+ _ application: UIApplication,
69
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
70
+ ) -> Bool {
71
+
72
+ OK.startMonitoring() // add this
73
+ return true
74
+ }
75
+ }
76
+ ```
77
+
78
+ </details>
79
+
80
+ <details>
81
+ <summary><b>Android Setup</b></summary>
82
+
83
+ Add OkHi Maven repository to `android/build.gradle`:
84
+
85
+ ```gradle
86
+ allprojects {
87
+ repositories {
88
+ maven { url "https://repo.okhi.io/artifactory/maven" }
89
+ }
90
+ }
91
+ ```
92
+
93
+ Add permissions to `AndroidManifest.xml`:
94
+
95
+ ```xml
96
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
97
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
98
+ <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
99
+ <uses-permission android:name="android.permission.INTERNET" />
100
+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
101
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
102
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" android:foregroundServiceType="location" />
103
+ ```
104
+
105
+ </details>
106
+
107
+ <details>
108
+ <summary><b>Expo Setup</b></summary>
109
+
110
+ > **Note:** Requires a development build. This library won't work with Expo Go.
111
+
112
+ ```bash
113
+ npx expo install react-native-okhi@beta
114
+ npx expo prebuild
115
+ npx expo run:ios # or run:android
116
+ ```
117
+
118
+ </details>
119
+
120
+ ### 3. Verify an address
121
+
122
+ ```typescript
123
+ import * as OkHi from 'react-native-okhi';
124
+
125
+ // Step 1
126
+ await OkHi.login({
127
+ auth: {
128
+ branchId: 'YOUR_BRANCH_ID',
129
+ clientKey: 'YOUR_CLIENT_KEY',
130
+ },
131
+ user: {
132
+ firstName: 'John',
133
+ lastName: 'Doe',
134
+ phone: '+254712345678',
135
+ email: 'john@example.com',
136
+ },
137
+ });
138
+
139
+ // Step 2
140
+ const { user, location } = await OkHi.startDigitalAddressVerification();
141
+ ```
142
+
143
+ ### Full Example
144
+
145
+ ```tsx
146
+ import { Button, Text, View } from 'react-native';
147
+ import * as OkHi from 'react-native-okhi';
148
+
149
+ export default function Dashboard() {
150
+ useEffect(() => {
151
+ OkHi.login({
152
+ auth: { branchId: 'YOUR_BRANCH_ID', clientKey: 'YOUR_CLIENT_KEY' },
153
+ user: {
154
+ firstName: 'John',
155
+ lastName: 'Doe',
156
+ phone: '+254712345678',
157
+ email: 'john@example.com',
158
+ },
159
+ }).then(() => console.log('user logged in'));
160
+ }, []);
161
+
162
+ const onButtonPress = async () => {
163
+ const { user, location } = await OkHi.startDigitalAddressVerification();
164
+ console.log(`started verification for: ${location.id}`);
165
+ };
166
+
167
+ return (
168
+ <View style={{ flex: 1, justifyContent: 'center', padding: 20 }}>
169
+ <Button title="Verify Address" onPress={onButtonPress} />
170
+ </View>
171
+ );
172
+ }
173
+ ```
174
+
175
+ ## License
36
176
 
37
- Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
177
+ MIT © [OkHi](https://okhi.co)
@@ -16,6 +16,6 @@ Pod::Spec.new do |s|
16
16
  s.source_files = "ios/**/*.{h,m,mm,swift,cpp}"
17
17
  s.private_header_files = "ios/**/*.h"
18
18
 
19
- s.dependency "OkHi", "1.10.6"
19
+ s.dependency "OkHi", "1.10.9"
20
20
  install_modules_dependencies(s)
21
21
  end
@@ -73,7 +73,7 @@ repositories {
73
73
  def kotlin_version = getExtOrDefault("kotlinVersion")
74
74
 
75
75
  dependencies {
76
- implementation 'io.okhi.android:okhi:1.0.0'
76
+ implementation 'io.okhi.android:okhi:1.0.5'
77
77
  implementation "com.facebook.react:react-android"
78
78
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
79
79
  }
@@ -50,10 +50,6 @@ class OkhiModule(reactContext: ReactApplicationContext) : NativeOkhiSpec(reactCo
50
50
  return NAME
51
51
  }
52
52
 
53
- override fun multiply(a: Double, b: Double): Double {
54
- return a * b
55
- }
56
-
57
53
  override fun login(credentials: ReadableMap?, callback: Callback?) {
58
54
  if (credentials == null) {
59
55
  callback?.invoke(null)
@@ -17,10 +17,6 @@ import UserNotifications
17
17
  okVerify.delegate = self
18
18
  }
19
19
 
20
- @objc public static func multiply(_ a: Double, _ b: Double) -> NSNumber {
21
- return NSNumber(value: a * b)
22
- }
23
-
24
20
  @objc public static func login(_ credentials: NSDictionary, callback: @escaping ([String]?) -> Void) {
25
21
  // Extract auth dictionary
26
22
  guard let authDict = credentials["auth"] as? NSDictionary,
@@ -54,7 +50,7 @@ import UserNotifications
54
50
  let auth = OkHiAuth(
55
51
  branchId: branchId,
56
52
  clientKey: clientKey,
57
- environment: env == "prod" ? .prod : .sandbox,
53
+ environment: env,
58
54
  appContext: nativeAppContext
59
55
  )
60
56
 
package/ios/Okhi.mm CHANGED
@@ -8,10 +8,6 @@
8
8
  #endif
9
9
 
10
10
  @implementation Okhi
11
- - (NSNumber *)multiply:(double)a b:(double)b {
12
- return [OkHiWrapper multiply:a :b];
13
- }
14
-
15
11
  - (void)login:(NSDictionary *)credentials callback:(RCTResponseSenderBlock)callback {
16
12
  [OkHiWrapper login:credentials callback:^(NSArray<NSString *> *results) {
17
13
  if (callback) {
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOkhi.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAqE,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAmEtDC,gCAAmB,CAACC,YAAY,CAAO,MAAM,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOkhi.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAqE,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAkEtDC,gCAAmB,CAACC,YAAY,CAAO,MAAM,CAAC","ignoreList":[]}
@@ -3,6 +3,26 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ login: true,
8
+ startDigitalAddressVerification: true,
9
+ startPhysicalAddressVerification: true,
10
+ startDigitalAndPhysicalAddressVerification: true,
11
+ createAddress: true,
12
+ isLocationServicesEnabled: true,
13
+ canOpenProtectedApps: true,
14
+ getLocationAccuracyLevel: true,
15
+ isBackgroundLocationPermissionGranted: true,
16
+ isCoarseLocationPermissionGranted: true,
17
+ isFineLocationPermissionGranted: true,
18
+ isPlayServicesAvailable: true,
19
+ isPostNotificationPermissionGranted: true,
20
+ openProtectedApps: true,
21
+ requestLocationPermission: true,
22
+ requestBackgroundLocationPermission: true,
23
+ requestEnableLocationServices: true,
24
+ requestPostNotificationPermissions: true
25
+ };
6
26
  exports.canOpenProtectedApps = canOpenProtectedApps;
7
27
  exports.createAddress = createAddress;
8
28
  exports.getLocationAccuracyLevel = getLocationAccuracyLevel;
@@ -13,7 +33,6 @@ exports.isLocationServicesEnabled = isLocationServicesEnabled;
13
33
  exports.isPlayServicesAvailable = isPlayServicesAvailable;
14
34
  exports.isPostNotificationPermissionGranted = isPostNotificationPermissionGranted;
15
35
  exports.login = login;
16
- exports.multiply = multiply;
17
36
  exports.openProtectedApps = openProtectedApps;
18
37
  exports.requestBackgroundLocationPermission = requestBackgroundLocationPermission;
19
38
  exports.requestEnableLocationServices = requestEnableLocationServices;
@@ -24,10 +43,85 @@ exports.startDigitalAndPhysicalAddressVerification = startDigitalAndPhysicalAddr
24
43
  exports.startPhysicalAddressVerification = startPhysicalAddressVerification;
25
44
  var _reactNative = require("react-native");
26
45
  var _NativeOkhi = _interopRequireDefault(require("./NativeOkhi"));
46
+ var _types = require("./types");
47
+ Object.keys(_types).forEach(function (key) {
48
+ if (key === "default" || key === "__esModule") return;
49
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
50
+ if (key in exports && exports[key] === _types[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _types[key];
55
+ }
56
+ });
57
+ });
27
58
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
- function multiply(a, b) {
29
- return _NativeOkhi.default.multiply(a, b);
30
- }
59
+ /**
60
+ * @packageDocumentation
61
+ * React Native OkHi SDK
62
+ *
63
+ * A comprehensive React Native library for address verification using OkHi's
64
+ * digital and physical verification methods.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * import * as OkHi from 'react-native-okhi';
69
+ *
70
+ * // 1. Login
71
+ * await OkHi.login({
72
+ * auth: { branchId: 'xxx', clientKey: 'xxx' },
73
+ * user: { firstName: 'John', lastName: 'Doe', phone: '+254...', email: '...' },
74
+ * });
75
+ *
76
+ * // 2. Start verification
77
+ * const result = await OkHi.startDigitalAddressVerification();
78
+ * console.log('Verified address:', result.location.formattedAddress);
79
+ * ```
80
+ */
81
+
82
+ /**
83
+ * Authenticates a user with the OkHi platform.
84
+ *
85
+ * @remarks
86
+ * This must be called before any verification functions. It establishes
87
+ * the user session and validates your API credentials.
88
+ *
89
+ * The login persists for the duration of the app session. You should call
90
+ * this when your user signs in or when starting an address verification flow.
91
+ *
92
+ * @param credentials - The login configuration containing auth credentials and user info
93
+ * @returns A promise that resolves with an array of permission strings that were granted,
94
+ * or `null` if `withPermissionsRequest` was not enabled
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * import * as OkHi from 'react-native-okhi';
99
+ * import type { OkHiLogin } from 'react-native-okhi';
100
+ *
101
+ * const credentials: OkHiLogin = {
102
+ * auth: {
103
+ * branchId: 'your_branch_id',
104
+ * clientKey: 'your_client_key',
105
+ * },
106
+ * user: {
107
+ * firstName: 'John',
108
+ * lastName: 'Doe',
109
+ * phone: '+254712345678',
110
+ * email: 'john.doe@example.com',
111
+ * },
112
+ * };
113
+ *
114
+ * try {
115
+ * await OkHi.login(credentials);
116
+ * console.log('Login successful');
117
+ * } catch (error) {
118
+ * console.error('Login failed:', error);
119
+ * }
120
+ * ```
121
+ *
122
+ * @see {@link OkHiLogin} - Configuration type
123
+ * @see {@link startDigitalAddressVerification} - Call after login to verify addresses
124
+ */
31
125
  function login(credentials) {
32
126
  return new Promise(resolve => {
33
127
  _NativeOkhi.default.login(credentials, results => {
@@ -64,23 +158,70 @@ function processVerificationResponse(response, error, resolve, reject) {
64
158
  });
65
159
  } else if (error != null) {
66
160
  const err = error;
67
- reject({
68
- code: err.code,
69
- message: err.message
70
- });
161
+ reject(_types.OkHiException.fromNativeError(err));
71
162
  } else {
72
- reject({
73
- code: 'unknown',
74
- message: 'unable to complete operation - unknown response'
75
- });
163
+ reject(new _types.OkHiException(_types.OkHiException.UNKNOWN, 'An unknown error occurred'));
76
164
  }
77
165
  } catch {
78
- reject({
79
- code: 'unknown',
80
- message: 'unable to complete operation - unknown error'
81
- });
166
+ reject(new _types.OkHiException(_types.OkHiException.UNKNOWN, 'An unknown error occurred'));
82
167
  }
83
168
  }
169
+
170
+ /**
171
+ * @remarks
172
+ * Starts the digital address verification flow.
173
+ *
174
+ * **Prerequisites:**
175
+ * - Must call {@link login} first
176
+ *
177
+ * @param okcollect - Optional configuration for styling and behavior
178
+ * @returns A promise that resolves with the user and location data
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * import * as OkHi from 'react-native-okhi';
183
+ *
184
+ * // Basic usage with defaults
185
+ * const result = await OkHi.startDigitalAddressVerification();
186
+ * console.log('Address:', result.location.formattedAddress);
187
+ * console.log('Location ID:', result.location.id);
188
+ * ```
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * import * as OkHi from 'react-native-okhi';
193
+ * import type { OkCollect } from 'react-native-okhi';
194
+ *
195
+ * // With custom styling
196
+ * const config: OkCollect = {
197
+ * style: {
198
+ * color: '#FF5722',
199
+ * logo: 'https://example.com/logo.png',
200
+ * },
201
+ * configuration: {
202
+ * streetView: true,
203
+ * },
204
+ * };
205
+ *
206
+ * const result = await OkHi.startDigitalAddressVerification(config);
207
+ * ```
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * import * as OkHi from 'react-native-okhi';
212
+ *
213
+ * // Start verification on previously created address
214
+ * const locationId: string = await fetchLocationIDFromMyDB()
215
+ * const result = await OkHi.startDigitalAddressVerification({
216
+ * locationId: locationId,
217
+ * });
218
+ * ```
219
+ *
220
+ * @see {@link OkCollect} - Configuration options
221
+ * @see {@link OkHiSuccessResponse} - Return type
222
+ * @see {@link startPhysicalAddressVerification} - For physical verification
223
+ * @see {@link startDigitalAndPhysicalAddressVerification} - For combined verification
224
+ */
84
225
  function startDigitalAddressVerification(okcollect) {
85
226
  const config = buildConfig(okcollect);
86
227
  return new Promise((resolve, reject) => {
@@ -89,6 +230,44 @@ function startDigitalAddressVerification(okcollect) {
89
230
  });
90
231
  });
91
232
  }
233
+
234
+ /**
235
+ * Starts the physical address verification flow.
236
+ *
237
+ * @remarks
238
+ * Physical verification requires an agent to visit the user's location
239
+ * in person.
240
+ *
241
+ * **Prerequisites:**
242
+ * - Must call {@link login} first
243
+ *
244
+ * @param okcollect - Optional configuration for styling and behavior
245
+ * @returns A promise that resolves with the user and location data
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * import * as OkHi from 'react-native-okhi';
250
+ *
251
+ * const result = await OkHi.startPhysicalAddressVerification();
252
+ * console.log('Verification requested for:', result.location.formattedAddress);
253
+ * console.log('Location ID for tracking:', result.location.id);
254
+ * ```
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * import * as OkHi from 'react-native-okhi';
259
+ *
260
+ * // With custom configuration
261
+ * const result = await OkHi.startPhysicalAddressVerification({
262
+ * style: { color: '#2196F3' },
263
+ * });
264
+ * ```
265
+ *
266
+ * @see {@link OkCollect} - Configuration options
267
+ * @see {@link OkHiSuccessResponse} - Return type
268
+ * @see {@link startDigitalAddressVerification} - For instant digital verification
269
+ * @see {@link startDigitalAndPhysicalAddressVerification} - For combined verification
270
+ */
92
271
  function startPhysicalAddressVerification(okcollect) {
93
272
  const config = buildConfig(okcollect);
94
273
  return new Promise((resolve, reject) => {
@@ -97,6 +276,48 @@ function startPhysicalAddressVerification(okcollect) {
97
276
  });
98
277
  });
99
278
  }
279
+
280
+ /**
281
+ * Starts both digital and physical address verification flows.
282
+ *
283
+ * @remarks
284
+ * This combines both verification methods for maximum confidence.
285
+ *
286
+ * **Prerequisites:**
287
+ * - Must call {@link login} first
288
+ *
289
+ * @param okcollect - Optional configuration for styling and behavior
290
+ * @returns A promise that resolves with the user and location data
291
+ *
292
+ * @example
293
+ * ```typescript
294
+ * import * as OkHi from 'react-native-okhi';
295
+ *
296
+ * const result = await OkHi.startDigitalAndPhysicalAddressVerification();
297
+ * console.log('Physical + Digital Verification started for:', result.location.id);
298
+ * ```
299
+ *
300
+ * @example
301
+ * ```typescript
302
+ * import * as OkHi from 'react-native-okhi';
303
+ *
304
+ * // With full customization
305
+ * const result = await OkHi.startDigitalAndPhysicalAddressVerification({
306
+ * style: {
307
+ * color: '#4CAF50',
308
+ * logo: 'https://example.com/logo.png',
309
+ * },
310
+ * configuration: {
311
+ * streetView: true,
312
+ * },
313
+ * });
314
+ * ```
315
+ *
316
+ * @see {@link OkCollect} - Configuration options
317
+ * @see {@link OkHiSuccessResponse} - Return type
318
+ * @see {@link startDigitalAddressVerification} - For digital-only verification
319
+ * @see {@link startPhysicalAddressVerification} - For physical-only verification
320
+ */
100
321
  function startDigitalAndPhysicalAddressVerification(okcollect) {
101
322
  const config = buildConfig(okcollect);
102
323
  return new Promise((resolve, reject) => {
@@ -105,6 +326,49 @@ function startDigitalAndPhysicalAddressVerification(okcollect) {
105
326
  });
106
327
  });
107
328
  }
329
+
330
+ /**
331
+ * Creates an address without starting verification.
332
+ *
333
+ * @remarks
334
+ * Use this when you want to collect and store an address but defer
335
+ * verification to a later time. The address can
336
+ * be verified later using the returned `locationId`.
337
+ *
338
+ * **Prerequisites:**
339
+ * - Must call {@link login} first
340
+ *
341
+ * @param okcollect - Optional configuration for styling and behavior
342
+ * @returns A promise that resolves with the user and location data
343
+ *
344
+ * @example
345
+ * ```typescript
346
+ * import * as OkHi from 'react-native-okhi';
347
+ *
348
+ * // Create address without verification
349
+ * const result = await OkHi.createAddress();
350
+ * console.log('Address created:', result.location.id);
351
+ *
352
+ * // Save the location ID to verify later
353
+ * const locationId = result.location.id;
354
+ * await saveToDatabase({ locationId: locationId });
355
+ * ```
356
+ *
357
+ * @example
358
+ * ```typescript
359
+ * import * as OkHi from 'react-native-okhi';
360
+ *
361
+ * // Later, verify the saved address
362
+ * const savedLocationId = await fetchLocationIdFromMyDB();
363
+ * const result = await OkHi.startDigitalAddressVerification({
364
+ * locationId: savedLocationId,
365
+ * });
366
+ * ```
367
+ *
368
+ * @see {@link OkCollect} - Configuration options
369
+ * @see {@link OkHiSuccessResponse} - Return type
370
+ * @see {@link startDigitalAddressVerification} - To verify an address
371
+ */
108
372
  function createAddress(okcollect) {
109
373
  const config = buildConfig(okcollect);
110
374
  return new Promise((resolve, reject) => {
@@ -118,10 +382,7 @@ function createAddress(okcollect) {
118
382
  function processBooleanResponse(result, error, resolve, reject) {
119
383
  if (error != null) {
120
384
  const err = error;
121
- reject({
122
- code: err.code,
123
- message: err.message
124
- });
385
+ reject(_types.OkHiException.fromNativeError(err));
125
386
  } else {
126
387
  resolve(result);
127
388
  }
@@ -131,17 +392,11 @@ function processBooleanResponse(result, error, resolve, reject) {
131
392
  function processStringResponse(result, error, resolve, reject) {
132
393
  if (error != null) {
133
394
  const err = error;
134
- reject({
135
- code: err.code,
136
- message: err.message
137
- });
395
+ reject(_types.OkHiException.fromNativeError(err));
138
396
  } else {
139
397
  resolve(result);
140
398
  }
141
399
  }
142
-
143
- // MARK: - Check Helpers
144
-
145
400
  function isLocationServicesEnabled() {
146
401
  return new Promise((resolve, reject) => {
147
402
  _NativeOkhi.default.isLocationServicesEnabled((result, error) => {
@@ -204,9 +459,6 @@ function openProtectedApps() {
204
459
  resolve();
205
460
  });
206
461
  }
207
-
208
- // MARK: - Request Helpers
209
-
210
462
  function requestLocationPermission() {
211
463
  return new Promise((resolve, reject) => {
212
464
  _NativeOkhi.default.requestLocationPermission((result, error) => {
@@ -231,10 +483,7 @@ function requestEnableLocationServices() {
231
483
  function requestPostNotificationPermissions() {
232
484
  return new Promise((resolve, reject) => {
233
485
  if (_reactNative.Platform.OS === 'ios') {
234
- reject({
235
- code: 'unsupported_platform',
236
- message: 'operation not supported'
237
- });
486
+ reject(new _types.OkHiException(_types.OkHiException.UNSUPPORTED_DEVICE, 'Notification permission request is not supported on iOS. Use iOS-specific notification APIs.'));
238
487
  } else {
239
488
  _NativeOkhi.default.requestPostNotificationPermissions((result, error) => {
240
489
  processBooleanResponse(result, error, resolve, reject);