react-native-radar 3.10.0-beta.5 → 3.10.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/android/build.gradle +2 -2
- package/android/src/main/java/io/radar/react/RNRadarModule.java +55 -6
- package/android/src/main/java/io/radar/react/RNRadarVerifiedReceiver.java +46 -0
- package/dist/package.json +1 -1
- package/dist/src/@types/RadarNativeInterface.d.ts +6 -5
- package/dist/src/@types/types.d.ts +9 -1
- package/dist/src/index.native.js +8 -6
- package/ios/Cartfile.resolved +1 -1
- package/ios/RNRadar.h +1 -1
- package/ios/RNRadar.m +64 -19
- package/package.json +1 -1
- package/react-native-radar.podspec +1 -1
- package/src/@types/RadarNativeInterface.ts +8 -5
- package/src/@types/types.ts +11 -1
- package/src/index.native.ts +16 -10
package/android/build.gradle
CHANGED
|
@@ -18,7 +18,7 @@ android {
|
|
|
18
18
|
minSdkVersion 16
|
|
19
19
|
targetSdkVersion 31
|
|
20
20
|
versionCode 1
|
|
21
|
-
versionName '3.10.
|
|
21
|
+
versionName '3.10.1'
|
|
22
22
|
}
|
|
23
23
|
lintOptions {
|
|
24
24
|
abortOnError false
|
|
@@ -45,5 +45,5 @@ repositories {
|
|
|
45
45
|
|
|
46
46
|
dependencies {
|
|
47
47
|
api 'com.facebook.react:react-native:+'
|
|
48
|
-
api 'io.radar:sdk:3.9.
|
|
48
|
+
api 'io.radar:sdk:3.9.4'
|
|
49
49
|
}
|
|
@@ -25,6 +25,7 @@ import io.radar.sdk.Radar;
|
|
|
25
25
|
import io.radar.sdk.RadarTrackingOptions;
|
|
26
26
|
import io.radar.sdk.RadarTrackingOptions.RadarTrackingOptionsForegroundService;
|
|
27
27
|
import io.radar.sdk.RadarTripOptions;
|
|
28
|
+
import io.radar.sdk.RadarVerifiedReceiver;
|
|
28
29
|
import io.radar.sdk.model.RadarAddress;
|
|
29
30
|
import io.radar.sdk.model.RadarContext;
|
|
30
31
|
import io.radar.sdk.model.RadarEvent;
|
|
@@ -49,16 +50,22 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
49
50
|
private Promise mPermissionsRequestPromise;
|
|
50
51
|
|
|
51
52
|
private RNRadarReceiver receiver;
|
|
53
|
+
private RNRadarVerifiedReceiver verifiedReceiver;
|
|
52
54
|
private int listenerCount = 0;
|
|
55
|
+
private boolean fraud = false;
|
|
53
56
|
|
|
54
57
|
public RNRadarModule(ReactApplicationContext reactContext) {
|
|
55
58
|
super(reactContext);
|
|
56
59
|
receiver = new RNRadarReceiver();
|
|
60
|
+
verifiedReceiver = new RNRadarVerifiedReceiver();
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
@ReactMethod
|
|
60
64
|
public void addListener(String eventName) {
|
|
61
65
|
if (listenerCount == 0) {
|
|
66
|
+
if (fraud) {
|
|
67
|
+
verifiedReceiver.hasListeners = true;
|
|
68
|
+
}
|
|
62
69
|
receiver.hasListeners = true;
|
|
63
70
|
}
|
|
64
71
|
|
|
@@ -69,6 +76,9 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
69
76
|
public void removeListeners(Integer count) {
|
|
70
77
|
listenerCount -= count;
|
|
71
78
|
if (listenerCount == 0) {
|
|
79
|
+
if (fraud) {
|
|
80
|
+
verifiedReceiver.hasListeners = false;
|
|
81
|
+
}
|
|
72
82
|
receiver.hasListeners = false;
|
|
73
83
|
}
|
|
74
84
|
}
|
|
@@ -80,8 +90,10 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
80
90
|
|
|
81
91
|
@ReactMethod
|
|
82
92
|
public void initialize(String publishableKey, boolean fraud) {
|
|
93
|
+
this.fraud = fraud;
|
|
83
94
|
if (fraud) {
|
|
84
95
|
Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud);
|
|
96
|
+
Radar.setVerifiedReceiver(verifiedReceiver);
|
|
85
97
|
} else {
|
|
86
98
|
Radar.initialize(getReactApplicationContext(), publishableKey);
|
|
87
99
|
Radar.setReceiver(receiver);
|
|
@@ -359,8 +371,17 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
359
371
|
}
|
|
360
372
|
|
|
361
373
|
@ReactMethod
|
|
362
|
-
public void trackVerified(final Promise promise) {
|
|
363
|
-
|
|
374
|
+
public void trackVerified(ReadableMap optionsMap, final Promise promise) {
|
|
375
|
+
|
|
376
|
+
boolean beaconsTrackingOption = false;
|
|
377
|
+
|
|
378
|
+
if (optionsMap != null) {
|
|
379
|
+
if (optionsMap.hasKey("beacons")) {
|
|
380
|
+
beaconsTrackingOption = optionsMap.getBoolean("beacons");
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
Radar.RadarTrackCallback trackCallback = new Radar.RadarTrackCallback() {
|
|
364
385
|
@Override
|
|
365
386
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable Location location, @Nullable RadarEvent[] events, @Nullable RadarUser user) {
|
|
366
387
|
if (promise == null) {
|
|
@@ -389,12 +410,23 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
389
410
|
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
|
|
390
411
|
}
|
|
391
412
|
}
|
|
392
|
-
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
Radar.trackVerified(beaconsTrackingOption, trackCallback);
|
|
393
416
|
}
|
|
394
417
|
|
|
395
418
|
@ReactMethod
|
|
396
|
-
public void trackVerifiedToken(final Promise promise) {
|
|
397
|
-
|
|
419
|
+
public void trackVerifiedToken(ReadableMap optionsMap, final Promise promise) {
|
|
420
|
+
|
|
421
|
+
boolean beaconsTrackingOption = false;
|
|
422
|
+
|
|
423
|
+
if (optionsMap != null) {
|
|
424
|
+
if (optionsMap.hasKey("beacons")) {
|
|
425
|
+
beaconsTrackingOption = optionsMap.getBoolean("beacons");
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
Radar.RadarTrackTokenCallback trackTokenCallback = new Radar.RadarTrackTokenCallback() {
|
|
398
430
|
@Override
|
|
399
431
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable String token) {
|
|
400
432
|
if (promise == null) {
|
|
@@ -417,7 +449,9 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
417
449
|
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
|
|
418
450
|
}
|
|
419
451
|
}
|
|
420
|
-
}
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
Radar.trackVerifiedToken(beaconsTrackingOption, trackTokenCallback);
|
|
421
455
|
}
|
|
422
456
|
|
|
423
457
|
@ReactMethod
|
|
@@ -446,6 +480,21 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
446
480
|
}
|
|
447
481
|
}
|
|
448
482
|
|
|
483
|
+
@ReactMethod
|
|
484
|
+
public void startTrackingVerified(ReadableMap optionsMap) {
|
|
485
|
+
boolean token = false;
|
|
486
|
+
boolean beacons = false;
|
|
487
|
+
int interval = 1;
|
|
488
|
+
|
|
489
|
+
if (optionsMap != null) {
|
|
490
|
+
token = optionsMap.hasKey("token") ? optionsMap.getBoolean("token") : token;
|
|
491
|
+
beacons = optionsMap.hasKey("beacons") ? optionsMap.getBoolean("beacons") : beacons;
|
|
492
|
+
interval = optionsMap.hasKey("interval") ? optionsMap.getInt("interval") : interval;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
Radar.startTrackingVerified(token, interval, beacons);
|
|
496
|
+
}
|
|
497
|
+
|
|
449
498
|
@ReactMethod
|
|
450
499
|
public void mockTracking(ReadableMap optionsMap) {
|
|
451
500
|
ReadableMap originMap = optionsMap.getMap("origin");
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
package io.radar.react;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.Log;
|
|
5
|
+
|
|
6
|
+
import androidx.annotation.NonNull;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.ReactApplication;
|
|
9
|
+
import com.facebook.react.ReactInstanceManager;
|
|
10
|
+
import com.facebook.react.ReactNativeHost;
|
|
11
|
+
import com.facebook.react.bridge.Arguments;
|
|
12
|
+
import com.facebook.react.bridge.ReactContext;
|
|
13
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
14
|
+
import com.facebook.react.bridge.WritableMap;
|
|
15
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
16
|
+
|
|
17
|
+
import io.radar.sdk.Radar;
|
|
18
|
+
import io.radar.sdk.RadarVerifiedReceiver;
|
|
19
|
+
|
|
20
|
+
public class RNRadarVerifiedReceiver extends RadarVerifiedReceiver {
|
|
21
|
+
|
|
22
|
+
private ReactNativeHost reactNativeHost;
|
|
23
|
+
private static final String TAG = "RNRadarVerifiedReceiver";
|
|
24
|
+
protected boolean hasListeners = false;
|
|
25
|
+
|
|
26
|
+
private void sendEvent(final String eventName, final Object data) {
|
|
27
|
+
final ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
|
|
28
|
+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
|
|
29
|
+
if (reactContext != null && hasListeners) {
|
|
30
|
+
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, data);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@Override
|
|
35
|
+
public void onTokenUpdated(@NonNull Context context, @NonNull String token) {
|
|
36
|
+
try {
|
|
37
|
+
ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
|
|
38
|
+
reactNativeHost = reactApplication.getReactNativeHost();
|
|
39
|
+
|
|
40
|
+
sendEvent("token", token);
|
|
41
|
+
} catch (Exception e) {
|
|
42
|
+
Log.e(TAG, "Exception", e);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
package/dist/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "React Native module for Radar, the leading geofencing and location tracking platform",
|
|
4
4
|
"homepage": "https://radar.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "3.10.
|
|
6
|
+
"version": "3.10.1",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"android",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Location, RadarAutocompleteOptions, RadarContextCallback, RadarAddressCallback, RadarGetDistanceOptions, RadarLocationCallback, RadarLogConversionCallback, RadarLogConversionOptions, RadarLogLevel, RadarMockTrackingOptions, RadarNotificationOptions, RadarPermissionsStatus, RadarRouteCallback, RadarRouteMatrix, RadarSearchGeofencesCallback, RadarSearchGeofencesOptions, RadarSearchPlacesCallback, RadarSearchPlacesOptions, RadarStartTripOptions, RadarTrackCallback, RadarTrackOnceOptions, RadarTrackTokenCallback, RadarTrackingOptions, RadarTrackingOptionsDesiredAccuracy, RadarTrackingOptionsForegroundService, RadarTripCallback, RadarTripOptions, RadarUpdateTripOptions,
|
|
1
|
+
import { Location, RadarAutocompleteOptions, RadarContextCallback, RadarAddressCallback, RadarEventChannel, RadarGetDistanceOptions, RadarLocationCallback, RadarLogConversionCallback, RadarLogConversionOptions, RadarLogLevel, RadarMockTrackingOptions, RadarNotificationOptions, RadarPermissionsStatus, RadarRouteCallback, RadarRouteMatrix, RadarSearchGeofencesCallback, RadarSearchGeofencesOptions, RadarSearchPlacesCallback, RadarSearchPlacesOptions, RadarStartTripOptions, RadarTrackCallback, RadarTrackOnceOptions, RadarTrackTokenCallback, RadarTrackingOptions, RadarTrackingOptionsDesiredAccuracy, RadarTrackingOptionsForegroundService, RadarTrackVerifiedOptions, RadarTripCallback, RadarTripOptions, RadarUpdateTripOptions, RadarVerifiedTrackingOptions, RadarListenerCallback, RadarGetMatrixOptions, RadarMetadata, RadarIPGeocodeCallback } from "./types";
|
|
2
2
|
export interface RadarNativeInterface {
|
|
3
3
|
initialize: (publishableKey: string, fraud: boolean) => void;
|
|
4
4
|
setLogLevel: (level: RadarLogLevel) => void;
|
|
@@ -13,12 +13,13 @@ export interface RadarNativeInterface {
|
|
|
13
13
|
requestPermissions: (background: boolean) => Promise<RadarPermissionsStatus>;
|
|
14
14
|
getLocation: (desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy) => Promise<RadarLocationCallback>;
|
|
15
15
|
trackOnce: (options?: RadarTrackOnceOptions | Location) => Promise<RadarTrackCallback>;
|
|
16
|
-
trackVerifiedToken: () => Promise<RadarTrackTokenCallback>;
|
|
17
|
-
trackVerified: () => Promise<RadarTrackCallback>;
|
|
16
|
+
trackVerifiedToken: (options?: RadarTrackVerifiedOptions) => Promise<RadarTrackTokenCallback>;
|
|
17
|
+
trackVerified: (options?: RadarTrackVerifiedOptions) => Promise<RadarTrackCallback>;
|
|
18
18
|
startTrackingEfficient: () => void;
|
|
19
19
|
startTrackingResponsive: () => void;
|
|
20
20
|
startTrackingContinuous: () => void;
|
|
21
21
|
startTrackingCustom: (options: RadarTrackingOptions) => void;
|
|
22
|
+
startTrackingVerified: (options?: RadarVerifiedTrackingOptions) => void;
|
|
22
23
|
mockTracking: (options: RadarMockTrackingOptions) => void;
|
|
23
24
|
stopTracking: () => void;
|
|
24
25
|
getTrackingOptions: () => Promise<RadarTrackingOptions>;
|
|
@@ -44,8 +45,8 @@ export interface RadarNativeInterface {
|
|
|
44
45
|
getMatrix: (option: RadarGetMatrixOptions) => Promise<RadarRouteMatrix>;
|
|
45
46
|
logConversion: (options: RadarLogConversionOptions) => Promise<RadarLogConversionCallback>;
|
|
46
47
|
sendEvent: (name: string, metadata: RadarMetadata) => void;
|
|
47
|
-
on: (
|
|
48
|
-
off: (
|
|
48
|
+
on: (channel: RadarEventChannel, callback: RadarListenerCallback) => void;
|
|
49
|
+
off: (channel: RadarEventChannel, callback?: Function | undefined) => void;
|
|
49
50
|
nativeSdkVersion: () => Promise<string>;
|
|
50
51
|
rnSdkVersion: () => string;
|
|
51
52
|
}
|
|
@@ -4,6 +4,9 @@ export interface RadarTrackOnceOptions {
|
|
|
4
4
|
desiredAccuracy?: RadarTrackingOptionsDesiredAccuracy;
|
|
5
5
|
beacons?: boolean;
|
|
6
6
|
}
|
|
7
|
+
export interface RadarTrackVerifiedOptions {
|
|
8
|
+
beacons?: boolean;
|
|
9
|
+
}
|
|
7
10
|
/**
|
|
8
11
|
* Options for tracking the user's location.
|
|
9
12
|
* @see {@link https://radar.com/documentation/sdk/tracking}
|
|
@@ -40,6 +43,11 @@ export interface RadarMockTrackingOptions {
|
|
|
40
43
|
steps: number;
|
|
41
44
|
interval: number;
|
|
42
45
|
}
|
|
46
|
+
export interface RadarVerifiedTrackingOptions {
|
|
47
|
+
token?: boolean;
|
|
48
|
+
interval?: number;
|
|
49
|
+
beacons?: boolean;
|
|
50
|
+
}
|
|
43
51
|
export interface RadarGetDistanceOptions {
|
|
44
52
|
origin?: Location;
|
|
45
53
|
destination?: Location;
|
|
@@ -212,7 +220,7 @@ export interface RadarLogUpdateCallback {
|
|
|
212
220
|
export type RadarListenerCallback = RadarEventUpdateCallback | RadarLocationUpdateCallback | RadarClientLocationUpdateCallback | RadarErrorCallback | RadarLogUpdateCallback;
|
|
213
221
|
export type RadarPermissionsStatus = "GRANTED_FOREGROUND" | "GRANTED_BACKGROUND" | "DENIED" | "NOT_DETERMINED" | "UNKNOWN";
|
|
214
222
|
export type RadarLocationSource = "FOREGROUND_LOCATION" | "BACKGROUND_LOCATION" | "MANUAL_LOCATION" | "VISIT_ARRIVAL" | "VISIT_DEPARTURE" | "GEOFENCE_ENTER" | "GEOFENCE_DWELL" | "GEOFENCE_EXIT" | "MOCK_LOCATION" | "BEACON_ENTER" | "BEACON_EXIT" | "UNKNOWN";
|
|
215
|
-
export type
|
|
223
|
+
export type RadarEventChannel = "clientLocation" | "location" | "error" | "events" | "log" | "token";
|
|
216
224
|
export type RadarLogLevel = "info" | "debug" | "warning" | "error" | "none";
|
|
217
225
|
export interface RadarRouteMatrix {
|
|
218
226
|
status: string;
|
package/dist/src/index.native.js
CHANGED
|
@@ -38,12 +38,13 @@ const trackOnce = (options) => {
|
|
|
38
38
|
}
|
|
39
39
|
return react_native_1.NativeModules.RNRadar.trackOnce(backCompatibleOptions);
|
|
40
40
|
};
|
|
41
|
-
const trackVerified = () => react_native_1.NativeModules.RNRadar.trackVerified();
|
|
42
|
-
const trackVerifiedToken = () => react_native_1.NativeModules.RNRadar.trackVerifiedToken();
|
|
41
|
+
const trackVerified = (options) => react_native_1.NativeModules.RNRadar.trackVerified(options);
|
|
42
|
+
const trackVerifiedToken = (options) => react_native_1.NativeModules.RNRadar.trackVerifiedToken(options);
|
|
43
43
|
const startTrackingEfficient = () => react_native_1.NativeModules.RNRadar.startTrackingEfficient();
|
|
44
44
|
const startTrackingResponsive = () => react_native_1.NativeModules.RNRadar.startTrackingResponsive();
|
|
45
45
|
const startTrackingContinuous = () => react_native_1.NativeModules.RNRadar.startTrackingContinuous();
|
|
46
46
|
const startTrackingCustom = (options) => react_native_1.NativeModules.RNRadar.startTrackingCustom(options);
|
|
47
|
+
const startTrackingVerified = (options) => react_native_1.NativeModules.RNRadar.startTrackingVerified(options);
|
|
47
48
|
const mockTracking = (options) => react_native_1.NativeModules.RNRadar.mockTracking(options);
|
|
48
49
|
const stopTracking = () => react_native_1.NativeModules.RNRadar.stopTracking();
|
|
49
50
|
const getTrackingOptions = () => react_native_1.NativeModules.RNRadar.getTrackingOptions();
|
|
@@ -69,14 +70,14 @@ const getDistance = (options) => react_native_1.NativeModules.RNRadar.getDistanc
|
|
|
69
70
|
const getMatrix = (options) => react_native_1.NativeModules.RNRadar.getMatrix(options);
|
|
70
71
|
const logConversion = (options) => react_native_1.NativeModules.RNRadar.logConversion(options);
|
|
71
72
|
const sendEvent = (name, metadata) => react_native_1.NativeModules.RNRadar.sendEvent(name, metadata);
|
|
72
|
-
const on = (
|
|
73
|
-
const off = (
|
|
73
|
+
const on = (channel, callback) => eventEmitter.addListener(channel, callback);
|
|
74
|
+
const off = (channel, callback) => {
|
|
74
75
|
if (callback) {
|
|
75
76
|
// @ts-ignore
|
|
76
|
-
eventEmitter.removeListener(
|
|
77
|
+
eventEmitter.removeListener(channel, callback);
|
|
77
78
|
}
|
|
78
79
|
else {
|
|
79
|
-
eventEmitter.removeAllListeners(
|
|
80
|
+
eventEmitter.removeAllListeners(channel);
|
|
80
81
|
}
|
|
81
82
|
};
|
|
82
83
|
const nativeSdkVersion = () => react_native_1.NativeModules.RNRadar.nativeSdkVersion();
|
|
@@ -102,6 +103,7 @@ const Radar = {
|
|
|
102
103
|
startTrackingResponsive,
|
|
103
104
|
startTrackingContinuous,
|
|
104
105
|
startTrackingCustom,
|
|
106
|
+
startTrackingVerified,
|
|
105
107
|
mockTracking,
|
|
106
108
|
stopTracking,
|
|
107
109
|
isTracking,
|
package/ios/Cartfile.resolved
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "radarlabs/radar-sdk-ios" "3.9.
|
|
1
|
+
github "radarlabs/radar-sdk-ios" "3.9.6"
|
package/ios/RNRadar.h
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
#import <React/RCTBridgeModule.h>
|
|
4
4
|
#import <React/RCTEventEmitter.h>
|
|
5
5
|
|
|
6
|
-
@interface RNRadar : RCTEventEmitter <RadarDelegate, RCTBridgeModule, CLLocationManagerDelegate>
|
|
6
|
+
@interface RNRadar : RCTEventEmitter <RadarDelegate, RadarVerifiedDelegate, RCTBridgeModule, CLLocationManagerDelegate>
|
|
7
7
|
|
|
8
8
|
@end
|
package/ios/RNRadar.m
CHANGED
|
@@ -16,6 +16,7 @@ RCT_EXPORT_MODULE();
|
|
|
16
16
|
self = [super init];
|
|
17
17
|
if (self) {
|
|
18
18
|
[Radar setDelegate:self];
|
|
19
|
+
[Radar setVerifiedDelegate:self];
|
|
19
20
|
locationManager = [CLLocationManager new];
|
|
20
21
|
locationManager.delegate = self;
|
|
21
22
|
}
|
|
@@ -38,7 +39,7 @@ RCT_EXPORT_MODULE();
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
- (NSArray<NSString *> *)supportedEvents {
|
|
41
|
-
return @[@"events", @"location", @"clientLocation", @"error", @"log"];
|
|
42
|
+
return @[@"events", @"location", @"clientLocation", @"error", @"log", @"token"];
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
- (void)startObserving {
|
|
@@ -91,6 +92,12 @@ RCT_EXPORT_MODULE();
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
95
|
+
- (void)didUpdateToken:(NSString *)token {
|
|
96
|
+
if (hasListeners) {
|
|
97
|
+
[self sendEventWithName:@"token" body:token];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
94
101
|
RCT_EXPORT_METHOD(initialize:(NSString *)publishableKey fraud:(BOOL)fraud) {
|
|
95
102
|
[Radar initializeWithPublishableKey:publishableKey];
|
|
96
103
|
}
|
|
@@ -231,7 +238,7 @@ RCT_EXPORT_METHOD(getLocation:(NSString *)desiredAccuracy resolve:(RCTPromiseRes
|
|
|
231
238
|
|
|
232
239
|
RCT_EXPORT_METHOD(trackOnce:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
233
240
|
RadarTrackingOptionsDesiredAccuracy desiredAccuracy;
|
|
234
|
-
BOOL
|
|
241
|
+
BOOL beacons = NO;
|
|
235
242
|
desiredAccuracy = RadarTrackingOptionsDesiredAccuracyMedium;
|
|
236
243
|
|
|
237
244
|
__block RCTPromiseResolveBlock resolver = resolve;
|
|
@@ -285,21 +292,28 @@ RCT_EXPORT_METHOD(trackOnce:(NSDictionary *)optionsDict resolve:(RCTPromiseResol
|
|
|
285
292
|
}
|
|
286
293
|
}
|
|
287
294
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
beaconsTrackingOption = beacons;
|
|
295
|
+
NSNumber *beaconsNumber = optionsDict[@"beacons"];
|
|
296
|
+
if (beaconsNumber != nil && [beaconsNumber isKindOfClass:[NSNumber class]]) {
|
|
297
|
+
beacons = [beaconsNumber boolValue];
|
|
292
298
|
}
|
|
293
299
|
|
|
294
|
-
[Radar trackOnceWithDesiredAccuracy:desiredAccuracy beacons:
|
|
300
|
+
[Radar trackOnceWithDesiredAccuracy:desiredAccuracy beacons:beacons completionHandler:completionHandler];
|
|
295
301
|
}
|
|
296
302
|
}
|
|
297
303
|
|
|
298
|
-
RCT_EXPORT_METHOD(trackVerified:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
RCT_EXPORT_METHOD(trackVerified:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
305
|
+
BOOL beacons = NO;
|
|
306
|
+
if (optionsDict != nil) {
|
|
307
|
+
NSNumber *beaconsNumber = optionsDict[@"beacons"];
|
|
308
|
+
if (beaconsNumber != nil && [beaconsNumber isKindOfClass:[NSNumber class]]) {
|
|
309
|
+
beacons = [beaconsNumber boolValue];
|
|
310
|
+
}
|
|
311
|
+
}
|
|
301
312
|
|
|
302
|
-
|
|
313
|
+
__block RCTPromiseResolveBlock resolver = resolve;
|
|
314
|
+
__block RCTPromiseRejectBlock rejecter = reject;
|
|
315
|
+
|
|
316
|
+
RadarTrackCompletionHandler completionHandler = ^(RadarStatus status, CLLocation * _Nullable location, NSArray<RadarEvent *> * _Nullable events, RadarUser * _Nullable user) {
|
|
303
317
|
if (status == RadarStatusSuccess && resolver) {
|
|
304
318
|
NSMutableDictionary *dict = [NSMutableDictionary new];
|
|
305
319
|
[dict setObject:[Radar stringForStatus:status] forKey:@"status"];
|
|
@@ -318,16 +332,24 @@ RCT_EXPORT_METHOD(trackVerified:(RCTPromiseResolveBlock)resolve reject:(RCTPromi
|
|
|
318
332
|
}
|
|
319
333
|
resolver = nil;
|
|
320
334
|
rejecter = nil;
|
|
321
|
-
};
|
|
335
|
+
};
|
|
322
336
|
|
|
323
|
-
[Radar
|
|
337
|
+
[Radar trackVerifiedWithBeacons:beacons completionHandler:completionHandler];
|
|
324
338
|
}
|
|
325
339
|
|
|
326
|
-
RCT_EXPORT_METHOD(trackVerifiedToken:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
327
|
-
|
|
328
|
-
|
|
340
|
+
RCT_EXPORT_METHOD(trackVerifiedToken:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
341
|
+
BOOL beacons = NO;
|
|
342
|
+
if (optionsDict != nil) {
|
|
343
|
+
NSNumber *beaconsNumber = optionsDict[@"beacons"];
|
|
344
|
+
if (beaconsNumber != nil && [beaconsNumber isKindOfClass:[NSNumber class]]) {
|
|
345
|
+
beacons = [beaconsNumber boolValue];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
__block RCTPromiseResolveBlock resolver = resolve;
|
|
350
|
+
__block RCTPromiseRejectBlock rejecter = reject;
|
|
329
351
|
|
|
330
|
-
|
|
352
|
+
RadarTrackTokenCompletionHandler completionHandler = ^(RadarStatus status, NSString * _Nullable token) {
|
|
331
353
|
if (status == RadarStatusSuccess && resolver) {
|
|
332
354
|
NSMutableDictionary *dict = [NSMutableDictionary new];
|
|
333
355
|
[dict setObject:[Radar stringForStatus:status] forKey:@"status"];
|
|
@@ -340,9 +362,9 @@ RCT_EXPORT_METHOD(trackVerifiedToken:(RCTPromiseResolveBlock)resolve reject:(RCT
|
|
|
340
362
|
}
|
|
341
363
|
resolver = nil;
|
|
342
364
|
rejecter = nil;
|
|
343
|
-
};
|
|
365
|
+
};
|
|
344
366
|
|
|
345
|
-
[Radar
|
|
367
|
+
[Radar trackVerifiedTokenWithBeacons:beacons completionHandler:completionHandler];
|
|
346
368
|
}
|
|
347
369
|
|
|
348
370
|
RCT_EXPORT_METHOD(startTrackingEfficient) {
|
|
@@ -362,6 +384,29 @@ RCT_EXPORT_METHOD(startTrackingCustom:(NSDictionary *)optionsDict) {
|
|
|
362
384
|
[Radar startTrackingWithOptions:options];
|
|
363
385
|
}
|
|
364
386
|
|
|
387
|
+
RCT_EXPORT_METHOD(startTrackingVerified:(NSDictionary *)optionsDict) {
|
|
388
|
+
BOOL token = NO;
|
|
389
|
+
BOOL beacons = NO;
|
|
390
|
+
double interval = 1;
|
|
391
|
+
|
|
392
|
+
if (optionsDict != nil) {
|
|
393
|
+
NSNumber *tokenNumber = optionsDict[@"token"];
|
|
394
|
+
if (tokenNumber != nil && [tokenNumber isKindOfClass:[NSNumber class]]) {
|
|
395
|
+
token = [tokenNumber boolValue];
|
|
396
|
+
}
|
|
397
|
+
NSNumber *beaconsNumber = optionsDict[@"beacons"];
|
|
398
|
+
if (beaconsNumber != nil && [beaconsNumber isKindOfClass:[NSNumber class]]) {
|
|
399
|
+
beacons = [beaconsNumber boolValue];
|
|
400
|
+
}
|
|
401
|
+
NSNumber *intervalNumber = optionsDict[@"interval"];
|
|
402
|
+
if (intervalNumber != nil && [intervalNumber isKindOfClass:[NSNumber class]]) {
|
|
403
|
+
interval = [intervalNumber doubleValue];
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
[Radar startTrackingVerified:token interval:interval beacons:beacons];
|
|
408
|
+
}
|
|
409
|
+
|
|
365
410
|
RCT_EXPORT_METHOD(mockTracking:(NSDictionary *)optionsDict) {
|
|
366
411
|
if (optionsDict == nil) {
|
|
367
412
|
return;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "React Native module for Radar, the leading geofencing and location tracking platform",
|
|
4
4
|
"homepage": "https://radar.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"version": "3.10.
|
|
6
|
+
"version": "3.10.1",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"android",
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
RadarAutocompleteOptions,
|
|
4
4
|
RadarContextCallback,
|
|
5
5
|
RadarAddressCallback,
|
|
6
|
+
RadarEventChannel,
|
|
6
7
|
RadarGetDistanceOptions,
|
|
7
8
|
RadarLocationCallback,
|
|
8
9
|
RadarLogConversionCallback,
|
|
@@ -24,10 +25,11 @@ import {
|
|
|
24
25
|
RadarTrackingOptions,
|
|
25
26
|
RadarTrackingOptionsDesiredAccuracy,
|
|
26
27
|
RadarTrackingOptionsForegroundService,
|
|
28
|
+
RadarTrackVerifiedOptions,
|
|
27
29
|
RadarTripCallback,
|
|
28
30
|
RadarTripOptions,
|
|
29
31
|
RadarUpdateTripOptions,
|
|
30
|
-
|
|
32
|
+
RadarVerifiedTrackingOptions,
|
|
31
33
|
RadarListenerCallback,
|
|
32
34
|
RadarGetMatrixOptions,
|
|
33
35
|
RadarMetadata,
|
|
@@ -52,12 +54,13 @@ export interface RadarNativeInterface {
|
|
|
52
54
|
trackOnce: (
|
|
53
55
|
options?: RadarTrackOnceOptions | Location
|
|
54
56
|
) => Promise<RadarTrackCallback>;
|
|
55
|
-
trackVerifiedToken: () => Promise<RadarTrackTokenCallback>;
|
|
56
|
-
trackVerified: () => Promise<RadarTrackCallback>;
|
|
57
|
+
trackVerifiedToken: (options?: RadarTrackVerifiedOptions) => Promise<RadarTrackTokenCallback>;
|
|
58
|
+
trackVerified: (options?: RadarTrackVerifiedOptions) => Promise<RadarTrackCallback>;
|
|
57
59
|
startTrackingEfficient: () => void;
|
|
58
60
|
startTrackingResponsive: () => void;
|
|
59
61
|
startTrackingContinuous: () => void;
|
|
60
62
|
startTrackingCustom: (options: RadarTrackingOptions) => void;
|
|
63
|
+
startTrackingVerified: (options?: RadarVerifiedTrackingOptions) => void;
|
|
61
64
|
mockTracking: (options: RadarMockTrackingOptions) => void;
|
|
62
65
|
stopTracking: () => void;
|
|
63
66
|
getTrackingOptions: () => Promise<RadarTrackingOptions>;
|
|
@@ -93,8 +96,8 @@ export interface RadarNativeInterface {
|
|
|
93
96
|
options: RadarLogConversionOptions
|
|
94
97
|
) => Promise<RadarLogConversionCallback>;
|
|
95
98
|
sendEvent: (name: string, metadata: RadarMetadata) => void;
|
|
96
|
-
on: (
|
|
97
|
-
off: (
|
|
99
|
+
on: (channel: RadarEventChannel, callback: RadarListenerCallback) => void;
|
|
100
|
+
off: (channel: RadarEventChannel, callback?: Function | undefined) => void;
|
|
98
101
|
nativeSdkVersion: () => Promise<string>;
|
|
99
102
|
rnSdkVersion: () => string;
|
|
100
103
|
}
|
package/src/@types/types.ts
CHANGED
|
@@ -6,6 +6,10 @@ export interface RadarTrackOnceOptions {
|
|
|
6
6
|
beacons?: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
export interface RadarTrackVerifiedOptions {
|
|
10
|
+
beacons?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
/**
|
|
10
14
|
* Options for tracking the user's location.
|
|
11
15
|
* @see {@link https://radar.com/documentation/sdk/tracking}
|
|
@@ -44,6 +48,12 @@ export interface RadarMockTrackingOptions {
|
|
|
44
48
|
interval: number;
|
|
45
49
|
}
|
|
46
50
|
|
|
51
|
+
export interface RadarVerifiedTrackingOptions {
|
|
52
|
+
token?: boolean;
|
|
53
|
+
interval?: number;
|
|
54
|
+
beacons?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
export interface RadarGetDistanceOptions {
|
|
48
58
|
origin?: Location;
|
|
49
59
|
destination?: Location;
|
|
@@ -273,7 +283,7 @@ export type RadarLocationSource =
|
|
|
273
283
|
| "BEACON_EXIT"
|
|
274
284
|
| "UNKNOWN";
|
|
275
285
|
|
|
276
|
-
export type
|
|
286
|
+
export type RadarEventChannel = "clientLocation" | "location" | "error" | "events" | "log" | "token";
|
|
277
287
|
|
|
278
288
|
export type RadarLogLevel = "info" | "debug" | "warning" | "error" | "none";
|
|
279
289
|
|
package/src/index.native.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
RadarAutocompleteOptions,
|
|
7
7
|
RadarContextCallback,
|
|
8
8
|
RadarAddressCallback,
|
|
9
|
+
RadarEventChannel,
|
|
9
10
|
RadarGetDistanceOptions,
|
|
10
11
|
RadarLocationCallback,
|
|
11
12
|
RadarLogConversionCallback,
|
|
@@ -30,11 +31,12 @@ import {
|
|
|
30
31
|
RadarTripCallback,
|
|
31
32
|
RadarTripOptions,
|
|
32
33
|
RadarUpdateTripOptions,
|
|
33
|
-
|
|
34
|
+
RadarVerifiedTrackingOptions,
|
|
34
35
|
RadarListenerCallback,
|
|
35
36
|
RadarGetMatrixOptions,
|
|
36
37
|
RadarMetadata,
|
|
37
38
|
RadarIPGeocodeCallback,
|
|
39
|
+
RadarTrackVerifiedOptions,
|
|
38
40
|
} from "./@types/types";
|
|
39
41
|
|
|
40
42
|
if (
|
|
@@ -103,11 +105,11 @@ const trackOnce = (
|
|
|
103
105
|
return NativeModules.RNRadar.trackOnce(backCompatibleOptions);
|
|
104
106
|
};
|
|
105
107
|
|
|
106
|
-
const trackVerified = (): Promise<RadarTrackCallback> =>
|
|
107
|
-
NativeModules.RNRadar.trackVerified();
|
|
108
|
+
const trackVerified = (options?: RadarTrackVerifiedOptions): Promise<RadarTrackCallback> =>
|
|
109
|
+
NativeModules.RNRadar.trackVerified(options);
|
|
108
110
|
|
|
109
|
-
const trackVerifiedToken = (): Promise<RadarTrackTokenCallback> =>
|
|
110
|
-
NativeModules.RNRadar.trackVerifiedToken();
|
|
111
|
+
const trackVerifiedToken = (options?: RadarTrackVerifiedOptions): Promise<RadarTrackTokenCallback> =>
|
|
112
|
+
NativeModules.RNRadar.trackVerifiedToken(options);
|
|
111
113
|
|
|
112
114
|
const startTrackingEfficient = (): void =>
|
|
113
115
|
NativeModules.RNRadar.startTrackingEfficient();
|
|
@@ -121,6 +123,9 @@ const startTrackingContinuous = (): void =>
|
|
|
121
123
|
const startTrackingCustom = (options: RadarTrackingOptions): void =>
|
|
122
124
|
NativeModules.RNRadar.startTrackingCustom(options);
|
|
123
125
|
|
|
126
|
+
const startTrackingVerified = (options?: RadarVerifiedTrackingOptions): void =>
|
|
127
|
+
NativeModules.RNRadar.startTrackingVerified(options);
|
|
128
|
+
|
|
124
129
|
const mockTracking = (options: RadarMockTrackingOptions): void =>
|
|
125
130
|
NativeModules.RNRadar.mockTracking(options);
|
|
126
131
|
|
|
@@ -205,15 +210,15 @@ const logConversion = (
|
|
|
205
210
|
const sendEvent = (name: string, metadata: RadarMetadata): void =>
|
|
206
211
|
NativeModules.RNRadar.sendEvent(name, metadata);
|
|
207
212
|
|
|
208
|
-
const on = (
|
|
209
|
-
eventEmitter.addListener(
|
|
213
|
+
const on = (channel: RadarEventChannel, callback: RadarListenerCallback): void =>
|
|
214
|
+
eventEmitter.addListener(channel, callback);
|
|
210
215
|
|
|
211
|
-
const off = (
|
|
216
|
+
const off = (channel: RadarEventChannel, callback?: Function | undefined): void => {
|
|
212
217
|
if (callback) {
|
|
213
218
|
// @ts-ignore
|
|
214
|
-
eventEmitter.removeListener(
|
|
219
|
+
eventEmitter.removeListener(channel, callback);
|
|
215
220
|
} else {
|
|
216
|
-
eventEmitter.removeAllListeners(
|
|
221
|
+
eventEmitter.removeAllListeners(channel);
|
|
217
222
|
}
|
|
218
223
|
};
|
|
219
224
|
|
|
@@ -243,6 +248,7 @@ const Radar: RadarNativeInterface = {
|
|
|
243
248
|
startTrackingResponsive,
|
|
244
249
|
startTrackingContinuous,
|
|
245
250
|
startTrackingCustom,
|
|
251
|
+
startTrackingVerified,
|
|
246
252
|
mockTracking,
|
|
247
253
|
stopTracking,
|
|
248
254
|
isTracking,
|