react-native-radar 3.21.0-beta.2 → 3.21.0

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.
@@ -1,40 +1,102 @@
1
- import type { EventSubscription } from 'react-native';
2
- import type { RadarNativeInterface } from './@types/RadarNativeInterface';
3
- import type { RadarTrackCallback, RadarTrackOnceOptions, RadarLocationUpdateCallback, RadarPermissionsStatus, RadarClientLocationUpdateCallback, RadarLocationSource, RadarErrorCallback, RadarLogUpdateCallback, RadarTokenUpdateCallback, RadarEventUpdateCallback, RadarLogLevel, RadarMetadata, RadarLocationCallback, RadarTrackingOptionsDesiredAccuracy, RadarTrackVerifiedCallback, RadarTrackVerifiedOptions, RadarMockTrackingOptions, RadarTrackingOptions, RadarVerifiedTrackingOptions, RadarContextCallback, RadarNotificationOptions, RadarStartTripOptions, RadarTrackingOptionsForegroundService, RadarTripCallback, RadarTripOptions, RadarUpdateTripOptions, RadarAddress, RadarAddressCallback, RadarAutocompleteOptions, RadarGeocodeOptions, RadarGetDistanceOptions, RadarGetMatrixOptions, RadarIPGeocodeCallback, RadarLogConversionCallback, RadarLogConversionOptions, RadarReverseGeocodeOptions, RadarRouteCallback, RadarRouteMatrix, RadarSearchGeofencesCallback, RadarSearchGeofencesOptions, RadarSearchPlacesCallback, RadarSearchPlacesOptions, RadarValidateAddressCallback,
4
- } from './@types/types';
5
- import { NativeEventEmitter, NativeModules } from 'react-native';
6
- import { VERSION } from './version';
7
-
8
- declare global {
9
- var __turboModuleProxy: any;
10
- }
11
-
12
- const isNewArchitecture = global.__turboModuleProxy != null;
13
-
14
- let NativeRadar: any;
15
-
16
- try {
17
- if (isNewArchitecture) {
18
- const NativeRadarModule = require('./NativeRadar');
19
- NativeRadar = NativeRadarModule.default;
20
- } else {
21
- NativeRadar = NativeModules.RNRadar;
1
+ import type { EventSubscription } from "react-native";
2
+ import type { RadarNativeInterface } from "./@types/RadarNativeInterface";
3
+ import type {
4
+ RadarTrackCallback,
5
+ RadarTrackOnceOptions,
6
+ RadarLocationUpdateCallback,
7
+ RadarPermissionsStatus,
8
+ RadarClientLocationUpdateCallback,
9
+ RadarLocationSource,
10
+ RadarErrorCallback,
11
+ RadarLogUpdateCallback,
12
+ RadarTokenUpdateCallback,
13
+ RadarEventUpdateCallback,
14
+ RadarLogLevel,
15
+ RadarMetadata,
16
+ RadarLocationCallback,
17
+ RadarTrackingOptionsDesiredAccuracy,
18
+ RadarTrackVerifiedCallback,
19
+ RadarTrackVerifiedOptions,
20
+ RadarMockTrackingOptions,
21
+ RadarTrackingOptions,
22
+ RadarVerifiedTrackingOptions,
23
+ RadarContextCallback,
24
+ RadarNotificationOptions,
25
+ RadarStartTripOptions,
26
+ RadarTrackingOptionsForegroundService,
27
+ RadarTripCallback,
28
+ RadarTripOptions,
29
+ RadarUpdateTripOptions,
30
+ RadarAddress,
31
+ RadarAddressCallback,
32
+ RadarAutocompleteOptions,
33
+ RadarGeocodeOptions,
34
+ RadarGetDistanceOptions,
35
+ RadarGetMatrixOptions,
36
+ RadarIPGeocodeCallback,
37
+ RadarLogConversionCallback,
38
+ RadarLogConversionOptions,
39
+ RadarReverseGeocodeOptions,
40
+ RadarRouteCallback,
41
+ RadarRouteMatrix,
42
+ RadarSearchGeofencesCallback,
43
+ RadarSearchGeofencesOptions,
44
+ RadarSearchPlacesCallback,
45
+ RadarSearchPlacesOptions,
46
+ RadarValidateAddressCallback,
47
+ RadarUser,
48
+ Location,
49
+ RadarEvent,
50
+ } from "./@types/types";
51
+ import { NativeEventEmitter, NativeModules } from "react-native";
52
+ import { VERSION } from "./version";
53
+ import NativeRadarMod, {
54
+ ClientLocationEmitter,
55
+ ErrorEmitter,
56
+ EventsEmitter,
57
+ LocationEmitter,
58
+ LogEmitter,
59
+ TokenEmitter,
60
+ } from "./NativeRadar";
61
+
62
+ const NativeRadar = NativeRadarMod;
63
+ // Comment above and uncomment below for QA logging
64
+ // const NativeRadar = new Proxy(NativeRadarMod, {
65
+ // get: function (target, name, receiver) {
66
+ // if (typeof target[name] == "function") {
67
+ // return function () {
68
+ // console.log("rn native:", name, "(", ...arguments, ")");
69
+ // return target[name].apply(target, arguments);
70
+ // };
71
+ // } else {
72
+ // return target[name];
73
+ // }
74
+ // },
75
+ // });
76
+
77
+ const compatEventEmitter =
78
+ NativeRadar.locationEmitter == null
79
+ ? new NativeEventEmitter(NativeModules.RNRadar)
80
+ : null;
81
+
82
+ type Events =
83
+ | "locationEmitter"
84
+ | "clientLocationEmitter"
85
+ | "errorEmitter"
86
+ | "logEmitter"
87
+ | "eventsEmitter"
88
+ | "tokenEmitter";
89
+
90
+ export function addListener<EventT extends Events>(
91
+ event: EventT,
92
+ handler: Parameters<(typeof NativeRadar)[EventT]>[0]
93
+ ): EventSubscription {
94
+ if (compatEventEmitter != null) {
95
+ return compatEventEmitter.addListener(event, handler);
22
96
  }
23
- } catch (error) {
24
- console.error('[Radar] Error loading NativeRadar module:', error);
25
- throw error;
97
+ return NativeRadar[event](handler as any);
26
98
  }
27
99
 
28
- // For old architecture, create a NativeEventEmitter
29
- const eventEmitter = isNewArchitecture ? null : new NativeEventEmitter(NativeModules.RNRadar);
30
-
31
- const locationEmitter = isNewArchitecture ? NativeRadar?.locationEmitter : null;
32
- const clientLocationEmitter = isNewArchitecture ? NativeRadar?.clientLocationEmitter : null;
33
- const errorEmitter = isNewArchitecture ? NativeRadar?.errorEmitter : null;
34
- const logEmitter = isNewArchitecture ? NativeRadar?.logEmitter : null;
35
- const eventsEmitter = isNewArchitecture ? NativeRadar?.eventsEmitter : null;
36
- const tokenEmitter = isNewArchitecture ? NativeRadar?.tokenEmitter : null;
37
-
38
100
  let locationUpdateSubscription: EventSubscription | null = null;
39
101
  let clientLocationUpdateSubscription: EventSubscription | null = null;
40
102
  let errorUpdateSubscription: EventSubscription | null = null;
@@ -48,220 +110,142 @@ const Radar: RadarNativeInterface = {
48
110
  },
49
111
 
50
112
  trackOnce: async (options?: RadarTrackOnceOptions) => {
51
- return NativeRadar.trackOnce(options || null) as Promise<RadarTrackCallback>;
113
+ return NativeRadar.trackOnce(
114
+ options || null
115
+ ) as Promise<RadarTrackCallback>;
52
116
  },
53
117
 
54
- onLocationUpdate: (callback: RadarLocationUpdateCallback) => {
118
+ onLocationUpdated: (callback: RadarLocationUpdateCallback | null) => {
55
119
  // Clear any existing subscription
56
120
  if (locationUpdateSubscription) {
57
121
  locationUpdateSubscription.remove();
58
- locationUpdateSubscription = null;
59
122
  }
60
123
 
61
- if (isNewArchitecture && locationEmitter) {
62
- locationUpdateSubscription = locationEmitter((event: { type: string; location: any; user: any; }) => {
63
- try {
64
- const locationUpdate = {
65
- location: event.location,
66
- user: event.user
67
- };
124
+ if (!callback) {
125
+ return;
126
+ }
68
127
 
69
- callback(locationUpdate);
70
- } catch (error) {
71
- console.error('[Radar] Error in location update callback:', error);
72
- }
73
- });
74
- } else if (!isNewArchitecture && eventEmitter) {
75
- locationUpdateSubscription = eventEmitter.addListener('location', (event: { location: any; user: any; }) => {
128
+ locationUpdateSubscription = addListener(
129
+ "locationEmitter",
130
+ (event: LocationEmitter) => {
76
131
  try {
77
132
  const locationUpdate = {
78
- location: event.location,
79
- user: event.user
133
+ location: event.location as Location,
134
+ user: event.user as RadarUser,
80
135
  };
81
-
82
136
  callback(locationUpdate);
83
137
  } catch (error) {
84
- console.error('[Radar] Error in location update callback:', error);
138
+ console.error("[Radar] Error in location update callback:", error);
85
139
  }
86
- });
87
- } else {
88
- console.warn('[Radar] No event emitter available for location updates');
89
- }
90
- },
91
-
92
- clearLocationUpdate: () => {
93
- if (locationUpdateSubscription) {
94
- locationUpdateSubscription.remove();
95
- locationUpdateSubscription = null;
96
- }
140
+ }
141
+ );
97
142
  },
98
143
 
99
- onClientLocationUpdate: (callback: RadarClientLocationUpdateCallback) => {
144
+ onClientLocationUpdated: (
145
+ callback: RadarClientLocationUpdateCallback | null
146
+ ) => {
100
147
  if (clientLocationUpdateSubscription) {
101
148
  clientLocationUpdateSubscription.remove();
102
149
  clientLocationUpdateSubscription = null;
103
150
  }
104
151
 
105
- if (isNewArchitecture && clientLocationEmitter) {
106
- clientLocationUpdateSubscription = clientLocationEmitter((event: { location: any; stopped: boolean; source: string; }) => {
107
- try {
108
- const clientLocationUpdate = {
109
- location: event.location,
110
- stopped: event.stopped,
111
- source: event.source as RadarLocationSource
112
- };
113
- callback(clientLocationUpdate);
114
- } catch (error) {
115
- console.error('[Radar] Error in client location update callback:', error);
116
- }
117
- });
118
- } else if (!isNewArchitecture && eventEmitter) {
119
- clientLocationUpdateSubscription = eventEmitter.addListener('clientLocation', (event: { location: any; stopped: boolean; source: string; }) => {
120
- try {
121
- const clientLocationUpdate = {
122
- location: event.location,
123
- stopped: event.stopped,
124
- source: event.source as RadarLocationSource
125
- };
126
- callback(clientLocationUpdate);
127
- } catch (error) {
128
- console.error('[Radar] Error in client location update callback:', error);
129
- }
130
- });
131
- } else {
132
- console.warn('[Radar] No event emitter available for client location updates');
152
+ if (!callback) {
153
+ return;
133
154
  }
134
- },
135
155
 
136
- clearClientLocationUpdate: () => {
137
- if (clientLocationUpdateSubscription) {
138
- clientLocationUpdateSubscription.remove();
139
- clientLocationUpdateSubscription = null;
140
- }
156
+ clientLocationUpdateSubscription = addListener(
157
+ "clientLocationEmitter",
158
+ (event: ClientLocationEmitter) => {
159
+ const clientLocationUpdate = {
160
+ location: event.location as Location,
161
+ stopped: event.stopped,
162
+ source: event.source as RadarLocationSource,
163
+ };
164
+ callback(clientLocationUpdate);
165
+ }
166
+ );
141
167
  },
142
168
 
143
- onError: (callback: RadarErrorCallback) => {
169
+ onError: (callback: RadarErrorCallback | null) => {
144
170
  if (errorUpdateSubscription) {
145
171
  errorUpdateSubscription.remove();
146
172
  errorUpdateSubscription = null;
147
173
  }
148
174
 
149
- if (isNewArchitecture && errorEmitter) {
150
- errorUpdateSubscription = errorEmitter((event: { status: string; }) => {
151
- callback(event.status);
152
- });
153
- } else if (!isNewArchitecture && eventEmitter) {
154
- errorUpdateSubscription = eventEmitter.addListener('error', (event: { status: string; }) => {
155
- callback(event.status);
156
- });
157
- } else {
158
- console.warn('[Radar] No event emitter available for error updates');
175
+ if (!callback) {
176
+ return;
159
177
  }
160
- },
161
178
 
162
- clearError: () => {
163
- if (errorUpdateSubscription) {
164
- errorUpdateSubscription.remove();
165
- errorUpdateSubscription = null;
166
- }
179
+ errorUpdateSubscription = addListener(
180
+ "errorEmitter",
181
+ (event: ErrorEmitter) => {
182
+ const errorUpdate = {
183
+ status: event.status,
184
+ };
185
+ callback(errorUpdate.status);
186
+ }
187
+ );
167
188
  },
168
189
 
169
- onLog: (callback: RadarLogUpdateCallback) => {
190
+ onLog: (callback: RadarLogUpdateCallback | null) => {
170
191
  if (logUpdateSubscription) {
171
192
  logUpdateSubscription.remove();
172
193
  logUpdateSubscription = null;
173
194
  }
174
195
 
175
- if (isNewArchitecture && logEmitter) {
176
- logUpdateSubscription = logEmitter((event: { message: string; }) => {
177
- callback(event.message);
178
- });
179
- } else if (!isNewArchitecture && eventEmitter) {
180
- logUpdateSubscription = eventEmitter.addListener('log', (event: { message: string; }) => {
181
- callback(event.message);
182
- });
183
- } else {
184
- console.warn('[Radar] No event emitter available for log updates');
196
+ if (!callback) {
197
+ return;
185
198
  }
186
- },
187
199
 
188
- clearLog: () => {
189
- if (logUpdateSubscription) {
190
- logUpdateSubscription.remove();
191
- logUpdateSubscription = null;
192
- }
200
+ logUpdateSubscription = addListener("logEmitter", (event: LogEmitter) => {
201
+ callback(event.message);
202
+ });
193
203
  },
194
204
 
195
- onEventUpdate: (callback: RadarEventUpdateCallback) => {
205
+ onEventsReceived: (callback: RadarEventUpdateCallback | null) => {
196
206
  if (eventsUpdateSubscription) {
197
207
  eventsUpdateSubscription.remove();
198
208
  eventsUpdateSubscription = null;
199
209
  }
200
210
 
201
- if (isNewArchitecture && eventsEmitter) {
202
- eventsUpdateSubscription = eventsEmitter((event: { events: any[]; user: any; }) => {
203
- try {
204
- const eventUpdate = {
205
- user: event.user,
206
- events: event.events
207
- };
208
- callback(eventUpdate);
209
- } catch (error) {
210
- console.error('[Radar] Error in event update callback:', error);
211
- }
212
- });
213
- } else if (!isNewArchitecture && eventEmitter) {
214
- eventsUpdateSubscription = eventEmitter.addListener('events', (event: { events: any[]; user: any; }) => {
215
- try {
216
- const eventUpdate = {
217
- user: event.user,
218
- events: event.events
219
- };
220
- callback(eventUpdate);
221
- } catch (error) {
222
- console.error('[Radar] Error in event update callback:', error);
223
- }
224
- });
225
- } else {
226
- console.warn('[Radar] No event emitter available for event updates');
211
+ if (!callback) {
212
+ return;
227
213
  }
228
- },
229
214
 
230
- clearEventUpdate: () => {
231
- if (eventsUpdateSubscription) {
232
- eventsUpdateSubscription.remove();
233
- eventsUpdateSubscription = null;
234
- }
215
+ eventsUpdateSubscription = addListener(
216
+ "eventsEmitter",
217
+ (event: EventsEmitter) => {
218
+ const eventUpdate = {
219
+ user: event.user as RadarUser,
220
+ events: event.events as RadarEvent[],
221
+ };
222
+ callback(eventUpdate);
223
+ }
224
+ );
235
225
  },
236
226
 
237
- onTokenUpdate: (callback: RadarTokenUpdateCallback) => {
227
+ onTokenUpdated: (callback: RadarTokenUpdateCallback | null) => {
238
228
  if (tokenUpdateSubscription) {
239
229
  tokenUpdateSubscription.remove();
240
230
  tokenUpdateSubscription = null;
241
231
  }
242
232
 
243
- if (isNewArchitecture && tokenEmitter) {
244
- tokenUpdateSubscription = tokenEmitter((event: { token: any; }) => {
245
- callback(event.token);
246
- });
247
- } else if (!isNewArchitecture && eventEmitter) {
248
- tokenUpdateSubscription = eventEmitter.addListener('token', (event: { token: any; }) => {
249
- callback(event.token);
250
- });
251
- } else {
252
- console.warn('[Radar] No event emitter available for token updates');
233
+ if (!callback) {
234
+ return;
253
235
  }
254
- },
255
236
 
256
- clearTokenUpdate: () => {
257
- if (tokenUpdateSubscription) {
258
- tokenUpdateSubscription.remove();
259
- tokenUpdateSubscription = null;
260
- }
237
+ tokenUpdateSubscription = addListener(
238
+ "tokenEmitter",
239
+ (event: TokenEmitter) => {
240
+ callback(event.token);
241
+ }
242
+ );
261
243
  },
262
244
 
263
245
  requestPermissions: (background: boolean) => {
264
- return NativeRadar.requestPermissions(background) as Promise<RadarPermissionsStatus>;
246
+ return NativeRadar.requestPermissions(
247
+ background
248
+ ) as Promise<RadarPermissionsStatus>;
265
249
  },
266
250
  setLogLevel: function (level: RadarLogLevel): void {
267
251
  return NativeRadar.setLogLevel(level);
@@ -282,22 +266,36 @@ const Radar: RadarNativeInterface = {
282
266
  return NativeRadar.setMetadata(metadata);
283
267
  },
284
268
  getMetadata: function (): Promise<RadarMetadata> {
285
- return NativeRadar.getMetadata();
269
+ return NativeRadar.getMetadata() as Promise<RadarMetadata>;
270
+ },
271
+ setProduct: function (product: string): void {
272
+ return NativeRadar.setProduct(product);
273
+ },
274
+ getProduct: function (): Promise<string> {
275
+ return NativeRadar.getProduct();
286
276
  },
287
277
  setAnonymousTrackingEnabled: function (enabled: boolean): void {
288
278
  return NativeRadar.setAnonymousTrackingEnabled(enabled);
289
279
  },
290
280
  getPermissionsStatus: function (): Promise<RadarPermissionsStatus> {
291
- return NativeRadar.getPermissionsStatus();
292
- },
293
- getLocation: function (desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy): Promise<RadarLocationCallback> {
294
- return NativeRadar.getLocation(desiredAccuracy);
295
- },
296
- trackVerified: function (options?: RadarTrackVerifiedOptions): Promise<RadarTrackVerifiedCallback> {
297
- return NativeRadar.trackVerified(options);
281
+ return NativeRadar.getPermissionsStatus() as Promise<RadarPermissionsStatus>;
282
+ },
283
+ getLocation: function (
284
+ desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy
285
+ ): Promise<RadarLocationCallback> {
286
+ return NativeRadar.getLocation(
287
+ desiredAccuracy || null
288
+ ) as Promise<RadarLocationCallback>;
289
+ },
290
+ trackVerified: function (
291
+ options?: RadarTrackVerifiedOptions
292
+ ): Promise<RadarTrackVerifiedCallback> {
293
+ return NativeRadar.trackVerified(
294
+ options || null
295
+ ) as Promise<RadarTrackVerifiedCallback>;
298
296
  },
299
297
  getVerifiedLocationToken: function (): Promise<RadarTrackVerifiedCallback> {
300
- return NativeRadar.getVerifiedLocationToken();
298
+ return NativeRadar.getVerifiedLocationToken() as Promise<RadarTrackVerifiedCallback>;
301
299
  },
302
300
  clearVerifiedLocationToken: function (): void {
303
301
  return NativeRadar.clearVerifiedLocationToken();
@@ -314,15 +312,14 @@ const Radar: RadarNativeInterface = {
314
312
  startTrackingCustom: function (options: RadarTrackingOptions): void {
315
313
  return NativeRadar.startTrackingCustom(options);
316
314
  },
317
- startTrackingVerified: function (options?: RadarVerifiedTrackingOptions): void {
318
- return NativeRadar.startTrackingVerified(options);
315
+ startTrackingVerified: function (
316
+ options?: RadarVerifiedTrackingOptions
317
+ ): void {
318
+ return NativeRadar.startTrackingVerified(options || null);
319
319
  },
320
320
  isTrackingVerified: function (): Promise<boolean> {
321
321
  return NativeRadar.isTrackingVerified();
322
322
  },
323
- setProduct: function (product: string): void {
324
- return NativeRadar.setProduct(product);
325
- },
326
323
  mockTracking: function (options: RadarMockTrackingOptions): void {
327
324
  return NativeRadar.mockTracking(options);
328
325
  },
@@ -333,7 +330,7 @@ const Radar: RadarNativeInterface = {
333
330
  return NativeRadar.stopTrackingVerified();
334
331
  },
335
332
  getTrackingOptions: function (): Promise<RadarTrackingOptions> {
336
- return NativeRadar.getTrackingOptions();
333
+ return NativeRadar.getTrackingOptions() as Promise<RadarTrackingOptions>;
337
334
  },
338
335
  isUsingRemoteTrackingOptions: function (): Promise<boolean> {
339
336
  return NativeRadar.isUsingRemoteTrackingOptions();
@@ -341,26 +338,32 @@ const Radar: RadarNativeInterface = {
341
338
  isTracking: function (): Promise<boolean> {
342
339
  return NativeRadar.isTracking();
343
340
  },
344
- setForegroundServiceOptions: function (options: RadarTrackingOptionsForegroundService): void {
341
+ setForegroundServiceOptions: function (
342
+ options: RadarTrackingOptionsForegroundService
343
+ ): void {
345
344
  return NativeRadar.setForegroundServiceOptions(options);
346
345
  },
347
346
  setNotificationOptions: function (options: RadarNotificationOptions): void {
348
347
  return NativeRadar.setNotificationOptions(options);
349
348
  },
350
349
  getTripOptions: function (): Promise<RadarTripOptions> {
351
- return NativeRadar.getTripOptions();
350
+ return NativeRadar.getTripOptions() as Promise<RadarTripOptions>;
352
351
  },
353
- startTrip: function (options: RadarStartTripOptions): Promise<RadarTripCallback> {
354
- return NativeRadar.startTrip(options);
352
+ startTrip: function (
353
+ options: RadarStartTripOptions
354
+ ): Promise<RadarTripCallback> {
355
+ return NativeRadar.startTrip(options) as Promise<RadarTripCallback>;
355
356
  },
356
357
  completeTrip: function (): Promise<RadarTripCallback> {
357
- return NativeRadar.completeTrip();
358
+ return NativeRadar.completeTrip() as Promise<RadarTripCallback>;
358
359
  },
359
360
  cancelTrip: function (): Promise<RadarTripCallback> {
360
- return NativeRadar.cancelTrip();
361
+ return NativeRadar.cancelTrip() as Promise<RadarTripCallback>;
361
362
  },
362
- updateTrip: function (options: RadarUpdateTripOptions): Promise<RadarTripCallback> {
363
- return NativeRadar.updateTrip(options);
363
+ updateTrip: function (
364
+ options: RadarUpdateTripOptions
365
+ ): Promise<RadarTripCallback> {
366
+ return NativeRadar.updateTrip(options) as Promise<RadarTripCallback>;
364
367
  },
365
368
  acceptEvent: function (eventId: string, verifiedPlaceId: string): void {
366
369
  return NativeRadar.acceptEvent(eventId, verifiedPlaceId);
@@ -369,37 +372,67 @@ const Radar: RadarNativeInterface = {
369
372
  return NativeRadar.rejectEvent(eventId);
370
373
  },
371
374
  getContext: function (location?: Location): Promise<RadarContextCallback> {
372
- return NativeRadar.getContext(location);
373
- },
374
- searchPlaces: function (options: RadarSearchPlacesOptions): Promise<RadarSearchPlacesCallback> {
375
- return NativeRadar.searchPlaces(options);
376
- },
377
- searchGeofences: function (options: RadarSearchGeofencesOptions): Promise<RadarSearchGeofencesCallback> {
378
- return NativeRadar.searchGeofences(options);
379
- },
380
- autocomplete: function (options: RadarAutocompleteOptions): Promise<RadarAddressCallback> {
381
- return NativeRadar.autocomplete(options);
382
- },
383
- geocode: function (options: RadarGeocodeOptions): Promise<RadarAddressCallback> {
384
- return NativeRadar.geocode(options);
385
- },
386
- reverseGeocode: function (options?: RadarReverseGeocodeOptions): Promise<RadarAddressCallback> {
387
- return NativeRadar.reverseGeocode(options);
375
+ return NativeRadar.getContext(
376
+ location || null
377
+ ) as Promise<RadarContextCallback>;
378
+ },
379
+ searchPlaces: function (
380
+ options: RadarSearchPlacesOptions
381
+ ): Promise<RadarSearchPlacesCallback> {
382
+ return NativeRadar.searchPlaces(
383
+ options
384
+ ) as Promise<RadarSearchPlacesCallback>;
385
+ },
386
+ searchGeofences: function (
387
+ options: RadarSearchGeofencesOptions
388
+ ): Promise<RadarSearchGeofencesCallback> {
389
+ return NativeRadar.searchGeofences(
390
+ options
391
+ ) as Promise<RadarSearchGeofencesCallback>;
392
+ },
393
+ autocomplete: function (
394
+ options: RadarAutocompleteOptions
395
+ ): Promise<RadarAddressCallback> {
396
+ return NativeRadar.autocomplete(options) as Promise<RadarAddressCallback>;
397
+ },
398
+ geocode: function (
399
+ options: RadarGeocodeOptions
400
+ ): Promise<RadarAddressCallback> {
401
+ return NativeRadar.geocode(options) as Promise<RadarAddressCallback>;
402
+ },
403
+ reverseGeocode: function (
404
+ options?: RadarReverseGeocodeOptions
405
+ ): Promise<RadarAddressCallback> {
406
+ return NativeRadar.reverseGeocode(
407
+ options || null
408
+ ) as Promise<RadarAddressCallback>;
388
409
  },
389
410
  ipGeocode: function (): Promise<RadarIPGeocodeCallback> {
390
- return NativeRadar.ipGeocode();
411
+ return NativeRadar.ipGeocode() as Promise<RadarIPGeocodeCallback>;
391
412
  },
392
- validateAddress: function (address: RadarAddress): Promise<RadarValidateAddressCallback> {
393
- return NativeRadar.validateAddress(address);
413
+ validateAddress: function (
414
+ address: RadarAddress
415
+ ): Promise<RadarValidateAddressCallback> {
416
+ return NativeRadar.validateAddress(
417
+ address
418
+ ) as Promise<RadarValidateAddressCallback>;
394
419
  },
395
- getDistance: function (option: RadarGetDistanceOptions): Promise<RadarRouteCallback> {
396
- return NativeRadar.getDistance(option);
420
+ getDistance: function (
421
+ option: RadarGetDistanceOptions
422
+ ): Promise<RadarRouteCallback> {
423
+ return NativeRadar.getDistance(option) as Promise<RadarRouteCallback>;
397
424
  },
398
- getMatrix: function (option: RadarGetMatrixOptions): Promise<RadarRouteMatrix> {
399
- return NativeRadar.getMatrix(option);
425
+ getMatrix: function (
426
+ option: RadarGetMatrixOptions
427
+ ): Promise<RadarRouteMatrix> {
428
+ return NativeRadar.getMatrix(option) as Promise<RadarRouteMatrix>;
400
429
  },
401
- logConversion: function (options: RadarLogConversionOptions): Promise<RadarLogConversionCallback> {
402
- return NativeRadar.logConversion(options);
430
+ logConversion: function (
431
+ options: RadarLogConversionOptions
432
+ ): Promise<RadarLogConversionCallback> {
433
+ return NativeRadar.logConversion(
434
+ options
435
+ ) as Promise<RadarLogConversionCallback>;
403
436
  },
404
437
 
405
438
  nativeSdkVersion: function (): Promise<string> {
@@ -413,7 +446,7 @@ const Radar: RadarNativeInterface = {
413
446
  },
414
447
  getPublishableKey: function (): Promise<string> {
415
448
  return NativeRadar.getPublishableKey();
416
- }
417
- }
449
+ },
450
+ };
418
451
 
419
452
  export default Radar;
package/src/index.tsx CHANGED
@@ -3,7 +3,10 @@ import { Platform } from "react-native";
3
3
 
4
4
  let nativeModule: RadarNativeInterface;
5
5
 
6
- nativeModule = Platform.OS === "web" ? require("./index.web").default : require("./index.native").default;
6
+ nativeModule =
7
+ Platform.OS === "web"
8
+ ? require("./index.web").default
9
+ : require("./index.native").default;
7
10
 
8
11
  export default nativeModule;
9
12
 
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file contains the version of the react-native-radar package
2
2
  // It should be updated to match the version in package.json
3
- export const VERSION = '3.21.0-beta.2';
3
+ export const VERSION = '3.21.0';