react-native-radar 3.11.0 → 3.12.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.
- package/android/build.gradle +2 -2
- package/android/src/main/java/io/radar/react/RNRadarModule.java +70 -77
- package/android/src/main/java/io/radar/react/RNRadarReceiver.java +13 -0
- package/android/src/main/java/io/radar/react/RNRadarVerifiedReceiver.java +3 -2
- package/dist/package.json +5 -1
- package/dist/src/@types/RadarNativeInterface.d.ts +5 -5
- package/dist/src/@types/types.d.ts +45 -5
- package/dist/src/index.native.js +4 -4
- package/ios/Cartfile.resolved +1 -1
- package/ios/RNRadar.m +108 -45
- package/package.json +5 -1
- package/react-native-radar.podspec +1 -1
- package/src/@types/RadarNativeInterface.ts +8 -5
- package/src/@types/types.ts +73 -5
- package/src/index.native.ts +11 -9
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.
|
|
21
|
+
versionName '3.12.0'
|
|
22
22
|
}
|
|
23
23
|
lintOptions {
|
|
24
24
|
abortOnError false
|
|
@@ -45,6 +45,6 @@ repositories {
|
|
|
45
45
|
|
|
46
46
|
dependencies {
|
|
47
47
|
api 'com.facebook.react:react-native:+'
|
|
48
|
-
api 'io.radar:sdk:3.
|
|
48
|
+
api 'io.radar:sdk:3.13.0'
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -32,11 +32,13 @@ import io.radar.sdk.model.RadarAddress;
|
|
|
32
32
|
import io.radar.sdk.model.RadarContext;
|
|
33
33
|
import io.radar.sdk.model.RadarEvent;
|
|
34
34
|
import io.radar.sdk.model.RadarGeofence;
|
|
35
|
+
import io.radar.sdk.model.RadarLocationPermissionStatus;
|
|
35
36
|
import io.radar.sdk.model.RadarPlace;
|
|
36
37
|
import io.radar.sdk.model.RadarRouteMatrix;
|
|
37
38
|
import io.radar.sdk.model.RadarRoutes;
|
|
38
39
|
import io.radar.sdk.model.RadarTrip;
|
|
39
40
|
import io.radar.sdk.model.RadarUser;
|
|
41
|
+
import io.radar.sdk.model.RadarVerifiedLocationToken;
|
|
40
42
|
import io.radar.sdk.RadarNotificationOptions;
|
|
41
43
|
|
|
42
44
|
import org.json.JSONException;
|
|
@@ -95,7 +97,7 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
95
97
|
this.fraud = fraud;
|
|
96
98
|
SharedPreferences.Editor editor = getReactApplicationContext().getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit();
|
|
97
99
|
editor.putString("x_platform_sdk_type", "ReactNative");
|
|
98
|
-
editor.putString("x_platform_sdk_version", "3.
|
|
100
|
+
editor.putString("x_platform_sdk_version", "3.12.0");
|
|
99
101
|
editor.apply();
|
|
100
102
|
if (fraud) {
|
|
101
103
|
Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud);
|
|
@@ -387,27 +389,16 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
387
389
|
}
|
|
388
390
|
}
|
|
389
391
|
|
|
390
|
-
Radar.
|
|
392
|
+
Radar.RadarTrackVerifiedCallback trackCallback = new Radar.RadarTrackVerifiedCallback() {
|
|
391
393
|
@Override
|
|
392
|
-
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable
|
|
394
|
+
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarVerifiedLocationToken token) {
|
|
393
395
|
if (promise == null) {
|
|
394
396
|
return;
|
|
395
397
|
}
|
|
396
398
|
|
|
397
399
|
try {
|
|
398
400
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
399
|
-
|
|
400
|
-
map.putString("status", status.toString());
|
|
401
|
-
if (location != null) {
|
|
402
|
-
map.putMap("location", RNRadarUtils.mapForJson(Radar.jsonForLocation(location)));
|
|
403
|
-
}
|
|
404
|
-
if (events != null) {
|
|
405
|
-
map.putArray("events", RNRadarUtils.arrayForJson(RadarEvent.toJson(events)));
|
|
406
|
-
}
|
|
407
|
-
if (user != null) {
|
|
408
|
-
map.putMap("user", RNRadarUtils.mapForJson(user.toJson()));
|
|
409
|
-
}
|
|
410
|
-
promise.resolve(map);
|
|
401
|
+
promise.resolve(token != null ? RNRadarUtils.mapForJson(token.toJson()) : null);
|
|
411
402
|
} else {
|
|
412
403
|
promise.reject(status.toString(), status.toString());
|
|
413
404
|
}
|
|
@@ -422,42 +413,28 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
422
413
|
}
|
|
423
414
|
|
|
424
415
|
@ReactMethod
|
|
425
|
-
public void
|
|
426
|
-
|
|
427
|
-
boolean beaconsTrackingOption = false;
|
|
428
|
-
|
|
429
|
-
if (optionsMap != null) {
|
|
430
|
-
if (optionsMap.hasKey("beacons")) {
|
|
431
|
-
beaconsTrackingOption = optionsMap.getBoolean("beacons");
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
Radar.RadarTrackTokenCallback trackTokenCallback = new Radar.RadarTrackTokenCallback() {
|
|
416
|
+
public void getVerifiedLocationToken(final Promise promise) {
|
|
417
|
+
Radar.RadarTrackVerifiedCallback trackCallback = new Radar.RadarTrackVerifiedCallback() {
|
|
436
418
|
@Override
|
|
437
|
-
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable
|
|
419
|
+
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarVerifiedLocationToken token) {
|
|
438
420
|
if (promise == null) {
|
|
439
421
|
return;
|
|
440
422
|
}
|
|
441
423
|
|
|
442
424
|
try {
|
|
443
425
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
444
|
-
|
|
445
|
-
map.putString("status", status.toString());
|
|
446
|
-
if (token != null) {
|
|
447
|
-
map.putString("token", token);
|
|
448
|
-
}
|
|
449
|
-
promise.resolve(map);
|
|
426
|
+
promise.resolve(token != null ? RNRadarUtils.mapForJson(token.toJson()) : null);
|
|
450
427
|
} else {
|
|
451
428
|
promise.reject(status.toString(), status.toString());
|
|
452
429
|
}
|
|
453
|
-
} catch (
|
|
454
|
-
Log.e(TAG, "
|
|
430
|
+
} catch (JSONException e) {
|
|
431
|
+
Log.e(TAG, "JSONException", e);
|
|
455
432
|
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
|
|
456
433
|
}
|
|
457
434
|
}
|
|
458
435
|
};
|
|
459
436
|
|
|
460
|
-
Radar.
|
|
437
|
+
Radar.getVerifiedLocationToken(trackCallback);
|
|
461
438
|
}
|
|
462
439
|
|
|
463
440
|
@ReactMethod
|
|
@@ -488,17 +465,15 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
488
465
|
|
|
489
466
|
@ReactMethod
|
|
490
467
|
public void startTrackingVerified(ReadableMap optionsMap) {
|
|
491
|
-
boolean token = false;
|
|
492
468
|
boolean beacons = false;
|
|
493
469
|
int interval = 1;
|
|
494
470
|
|
|
495
471
|
if (optionsMap != null) {
|
|
496
|
-
token = optionsMap.hasKey("token") ? optionsMap.getBoolean("token") : token;
|
|
497
472
|
beacons = optionsMap.hasKey("beacons") ? optionsMap.getBoolean("beacons") : beacons;
|
|
498
473
|
interval = optionsMap.hasKey("interval") ? optionsMap.getInt("interval") : interval;
|
|
499
474
|
}
|
|
500
475
|
|
|
501
|
-
Radar.startTrackingVerified(
|
|
476
|
+
Radar.startTrackingVerified(interval, beacons);
|
|
502
477
|
}
|
|
503
478
|
|
|
504
479
|
@ReactMethod
|
|
@@ -1022,40 +997,22 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1022
997
|
}
|
|
1023
998
|
|
|
1024
999
|
@ReactMethod
|
|
1025
|
-
public void geocode(
|
|
1000
|
+
public void geocode(ReadableMap optionsMap, final Promise promise) {
|
|
1026
1001
|
if (promise == null) {
|
|
1027
1002
|
return;
|
|
1028
1003
|
}
|
|
1029
1004
|
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
|
|
1033
|
-
if (status == Radar.RadarStatus.SUCCESS) {
|
|
1034
|
-
try {
|
|
1035
|
-
WritableMap map = Arguments.createMap();
|
|
1036
|
-
map.putString("status", status.toString());
|
|
1037
|
-
if (addresses != null) {
|
|
1038
|
-
map.putArray("addresses", RNRadarUtils.arrayForJson(RadarAddress.toJson(addresses)));
|
|
1039
|
-
}
|
|
1040
|
-
promise.resolve(map);
|
|
1041
|
-
} catch (JSONException e) {
|
|
1042
|
-
Log.e(TAG, "JSONException", e);
|
|
1043
|
-
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
|
|
1044
|
-
}
|
|
1045
|
-
} else {
|
|
1046
|
-
promise.reject(status.toString(), status.toString());
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1005
|
+
if (!optionsMap.hasKey("address")) {
|
|
1006
|
+
promise.reject(Radar.RadarStatus.ERROR_BAD_REQUEST.toString(), Radar.RadarStatus.ERROR_BAD_REQUEST.toString());
|
|
1051
1007
|
|
|
1052
|
-
@ReactMethod
|
|
1053
|
-
public void reverseGeocode(final Promise promise) {
|
|
1054
|
-
if (promise == null) {
|
|
1055
1008
|
return;
|
|
1056
1009
|
}
|
|
1057
1010
|
|
|
1058
|
-
|
|
1011
|
+
String address = optionsMap.getString("address");
|
|
1012
|
+
String[] layers = optionsMap.hasKey("layers") ? RNRadarUtils.stringArrayForArray(optionsMap.getArray("layers")) : null;
|
|
1013
|
+
String[] countries = optionsMap.hasKey("countries") ? RNRadarUtils.stringArrayForArray(optionsMap.getArray("countries")) : null;
|
|
1014
|
+
|
|
1015
|
+
Radar.geocode(address, layers, countries, new Radar.RadarGeocodeCallback() {
|
|
1059
1016
|
@Override
|
|
1060
1017
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
|
|
1061
1018
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
@@ -1078,24 +1035,20 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1078
1035
|
}
|
|
1079
1036
|
|
|
1080
1037
|
@ReactMethod
|
|
1081
|
-
public void reverseGeocode(ReadableMap
|
|
1038
|
+
public void reverseGeocode(ReadableMap optionsMap, final Promise promise) {
|
|
1082
1039
|
if (promise == null) {
|
|
1083
1040
|
return;
|
|
1084
1041
|
}
|
|
1085
1042
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1043
|
+
ReadableMap locationMap = null;
|
|
1044
|
+
String[] layers = null;
|
|
1088
1045
|
|
|
1089
|
-
|
|
1046
|
+
if (optionsMap != null) {
|
|
1047
|
+
locationMap = optionsMap.getMap("location");
|
|
1048
|
+
layers = optionsMap.hasKey("layers") ? RNRadarUtils.stringArrayForArray(optionsMap.getArray("layers")) : null;
|
|
1090
1049
|
}
|
|
1091
1050
|
|
|
1092
|
-
|
|
1093
|
-
double longitude = locationMap.getDouble("longitude");
|
|
1094
|
-
Location location = new Location("RNRadarModule");
|
|
1095
|
-
location.setLatitude(latitude);
|
|
1096
|
-
location.setLongitude(longitude);
|
|
1097
|
-
|
|
1098
|
-
Radar.reverseGeocode(location, new Radar.RadarGeocodeCallback() {
|
|
1051
|
+
Radar.RadarGeocodeCallback callback = new Radar.RadarGeocodeCallback() {
|
|
1099
1052
|
@Override
|
|
1100
1053
|
public void onComplete(@NonNull Radar.RadarStatus status, @Nullable RadarAddress[] addresses) {
|
|
1101
1054
|
if (status == Radar.RadarStatus.SUCCESS) {
|
|
@@ -1114,7 +1067,19 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1114
1067
|
promise.reject(status.toString(), status.toString());
|
|
1115
1068
|
}
|
|
1116
1069
|
}
|
|
1117
|
-
}
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
if (locationMap != null) {
|
|
1073
|
+
double latitude = locationMap.getDouble("latitude");
|
|
1074
|
+
double longitude = locationMap.getDouble("longitude");
|
|
1075
|
+
Location location = new Location("RNRadarModule");
|
|
1076
|
+
location.setLatitude(latitude);
|
|
1077
|
+
location.setLongitude(longitude);
|
|
1078
|
+
|
|
1079
|
+
Radar.reverseGeocode(location, layers, callback);
|
|
1080
|
+
} else {
|
|
1081
|
+
Radar.reverseGeocode(layers, callback);
|
|
1082
|
+
}
|
|
1118
1083
|
}
|
|
1119
1084
|
|
|
1120
1085
|
@ReactMethod
|
|
@@ -1330,4 +1295,32 @@ public class RNRadarModule extends ReactContextBaseJavaModule implements Permiss
|
|
|
1330
1295
|
}
|
|
1331
1296
|
}
|
|
1332
1297
|
|
|
1298
|
+
@ReactMethod
|
|
1299
|
+
public void requestForegroundLocationPermission() {
|
|
1300
|
+
Radar.requestForegroundLocationPermission();
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
@ReactMethod
|
|
1304
|
+
public void requestBackgroundLocationPermission() {
|
|
1305
|
+
Radar.requestBackgroundLocationPermission();
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
@ReactMethod
|
|
1309
|
+
public void getLocationPermissionStatus(final Promise promise) {
|
|
1310
|
+
if (promise == null) {
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
try {
|
|
1314
|
+
RadarLocationPermissionStatus options = Radar.getLocationPermissionStatus();
|
|
1315
|
+
promise.resolve(RNRadarUtils.mapForJson(options.toJson()));
|
|
1316
|
+
} catch(JSONException e) {
|
|
1317
|
+
Log.e(TAG, "JSONException", e);
|
|
1318
|
+
promise.reject(Radar.RadarStatus.ERROR_SERVER.toString(), Radar.RadarStatus.ERROR_SERVER.toString());
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
@ReactMethod
|
|
1323
|
+
public void openAppSettings() {
|
|
1324
|
+
Radar.openAppSettings();
|
|
1325
|
+
}
|
|
1333
1326
|
}
|
|
@@ -20,6 +20,7 @@ import io.radar.sdk.Radar;
|
|
|
20
20
|
import io.radar.sdk.RadarReceiver;
|
|
21
21
|
import io.radar.sdk.model.RadarEvent;
|
|
22
22
|
import io.radar.sdk.model.RadarUser;
|
|
23
|
+
import io.radar.sdk.model.RadarLocationPermissionStatus;
|
|
23
24
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
24
25
|
|
|
25
26
|
public class RNRadarReceiver extends RadarReceiver {
|
|
@@ -111,4 +112,16 @@ public class RNRadarReceiver extends RadarReceiver {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
|
|
115
|
+
@Override
|
|
116
|
+
public void onLocationPermissionStatusUpdated(@NonNull Context context, @NonNull RadarLocationPermissionStatus status) {
|
|
117
|
+
try {
|
|
118
|
+
ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
|
|
119
|
+
reactNativeHost = reactApplication.getReactNativeHost();
|
|
120
|
+
|
|
121
|
+
sendEvent("locationPermissionStatus", RNRadarUtils.mapForJson(status.toJson()));
|
|
122
|
+
} catch (Exception e) {
|
|
123
|
+
Log.e(TAG, "Exception", e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
114
127
|
}
|
|
@@ -16,6 +16,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
|
16
16
|
|
|
17
17
|
import io.radar.sdk.Radar;
|
|
18
18
|
import io.radar.sdk.RadarVerifiedReceiver;
|
|
19
|
+
import io.radar.sdk.model.RadarVerifiedLocationToken;
|
|
19
20
|
|
|
20
21
|
public class RNRadarVerifiedReceiver extends RadarVerifiedReceiver {
|
|
21
22
|
|
|
@@ -32,12 +33,12 @@ public class RNRadarVerifiedReceiver extends RadarVerifiedReceiver {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
@Override
|
|
35
|
-
public void onTokenUpdated(@NonNull Context context, @NonNull
|
|
36
|
+
public void onTokenUpdated(@NonNull Context context, @NonNull RadarVerifiedLocationToken token) {
|
|
36
37
|
try {
|
|
37
38
|
ReactApplication reactApplication = ((ReactApplication)context.getApplicationContext());
|
|
38
39
|
reactNativeHost = reactApplication.getReactNativeHost();
|
|
39
40
|
|
|
40
|
-
sendEvent("token", token);
|
|
41
|
+
sendEvent("token", RNRadarUtils.mapForJson(token.toJson()));
|
|
41
42
|
} catch (Exception e) {
|
|
42
43
|
Log.e(TAG, "Exception", e);
|
|
43
44
|
}
|
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.
|
|
6
|
+
"version": "3.12.0",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"android",
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"reporters": [
|
|
28
28
|
"default",
|
|
29
29
|
"jest-junit"
|
|
30
|
+
],
|
|
31
|
+
"modulePathIgnorePatterns": [
|
|
32
|
+
"example",
|
|
33
|
+
"example2"
|
|
30
34
|
]
|
|
31
35
|
},
|
|
32
36
|
"peerDependencies": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Location, RadarAutocompleteOptions, RadarContextCallback, RadarAddressCallback, RadarEventChannel, RadarGetDistanceOptions, RadarLocationCallback, RadarLogConversionCallback, RadarLogConversionOptions, RadarLogLevel, RadarMockTrackingOptions, RadarNotificationOptions, RadarPermissionsStatus, RadarRouteCallback, RadarRouteMatrix, RadarSearchGeofencesCallback, RadarSearchGeofencesOptions, RadarSearchPlacesCallback, RadarSearchPlacesOptions, RadarStartTripOptions, RadarTrackCallback, RadarTrackOnceOptions,
|
|
1
|
+
import { Location, RadarAutocompleteOptions, RadarContextCallback, RadarAddressCallback, RadarEventChannel, RadarGeocodeOptions, RadarGetDistanceOptions, RadarLocationCallback, RadarLogConversionCallback, RadarLogConversionOptions, RadarLogLevel, RadarMockTrackingOptions, RadarNotificationOptions, RadarPermissionsStatus, RadarReverseGeocodeOptions, RadarRouteCallback, RadarRouteMatrix, RadarSearchGeofencesCallback, RadarSearchGeofencesOptions, RadarSearchPlacesCallback, RadarSearchPlacesOptions, RadarStartTripOptions, RadarTrackCallback, RadarTrackOnceOptions, RadarTrackVerifiedCallback, 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,8 +13,8 @@ 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
|
-
|
|
17
|
-
|
|
16
|
+
trackVerified: (options?: RadarTrackVerifiedOptions) => Promise<RadarTrackVerifiedCallback>;
|
|
17
|
+
getVerifiedLocationToken: () => Promise<RadarTrackVerifiedCallback>;
|
|
18
18
|
startTrackingEfficient: () => void;
|
|
19
19
|
startTrackingResponsive: () => void;
|
|
20
20
|
startTrackingContinuous: () => void;
|
|
@@ -38,8 +38,8 @@ export interface RadarNativeInterface {
|
|
|
38
38
|
searchPlaces: (options: RadarSearchPlacesOptions) => Promise<RadarSearchPlacesCallback>;
|
|
39
39
|
searchGeofences: (options: RadarSearchGeofencesOptions) => Promise<RadarSearchGeofencesCallback>;
|
|
40
40
|
autocomplete: (options: RadarAutocompleteOptions) => Promise<RadarAddressCallback>;
|
|
41
|
-
geocode: (
|
|
42
|
-
reverseGeocode: (
|
|
41
|
+
geocode: (options: RadarGeocodeOptions) => Promise<RadarAddressCallback>;
|
|
42
|
+
reverseGeocode: (options?: RadarReverseGeocodeOptions) => Promise<RadarAddressCallback>;
|
|
43
43
|
ipGeocode: () => Promise<RadarIPGeocodeCallback>;
|
|
44
44
|
getDistance: (option: RadarGetDistanceOptions) => Promise<RadarRouteCallback>;
|
|
45
45
|
getMatrix: (option: RadarGetMatrixOptions) => Promise<RadarRouteMatrix>;
|
|
@@ -53,10 +53,17 @@ export interface RadarMockTrackingOptions {
|
|
|
53
53
|
interval: number;
|
|
54
54
|
}
|
|
55
55
|
export interface RadarVerifiedTrackingOptions {
|
|
56
|
-
token?: boolean;
|
|
57
56
|
interval?: number;
|
|
58
57
|
beacons?: boolean;
|
|
59
58
|
}
|
|
59
|
+
export interface RadarVerifiedLocationToken {
|
|
60
|
+
user: RadarUser;
|
|
61
|
+
events: RadarEvent[];
|
|
62
|
+
token: string;
|
|
63
|
+
expiresAt: Date;
|
|
64
|
+
expiresIn: number;
|
|
65
|
+
passed: boolean;
|
|
66
|
+
}
|
|
60
67
|
export interface RadarGetDistanceOptions {
|
|
61
68
|
origin?: Location;
|
|
62
69
|
destination?: Location;
|
|
@@ -115,6 +122,15 @@ export interface RadarAutocompleteOptions {
|
|
|
115
122
|
expandUnits?: boolean;
|
|
116
123
|
mailable?: boolean;
|
|
117
124
|
}
|
|
125
|
+
export interface RadarGeocodeOptions {
|
|
126
|
+
address: string;
|
|
127
|
+
layers?: string[];
|
|
128
|
+
countries?: string[];
|
|
129
|
+
}
|
|
130
|
+
export interface RadarReverseGeocodeOptions {
|
|
131
|
+
location?: Location;
|
|
132
|
+
layers?: string[];
|
|
133
|
+
}
|
|
118
134
|
export interface RadarNotificationOptions {
|
|
119
135
|
iconString?: string;
|
|
120
136
|
iconColor?: string;
|
|
@@ -195,9 +211,9 @@ export interface RadarLogConversionCallback {
|
|
|
195
211
|
status: string;
|
|
196
212
|
event?: RadarEvent;
|
|
197
213
|
}
|
|
198
|
-
export interface
|
|
214
|
+
export interface RadarTrackVerifiedCallback {
|
|
199
215
|
status: string;
|
|
200
|
-
token?:
|
|
216
|
+
token?: RadarVerifiedLocationToken;
|
|
201
217
|
}
|
|
202
218
|
export interface RadarEventUpdate {
|
|
203
219
|
user?: RadarUser;
|
|
@@ -227,10 +243,13 @@ export interface RadarErrorCallback {
|
|
|
227
243
|
export interface RadarLogUpdateCallback {
|
|
228
244
|
(status: string): void;
|
|
229
245
|
}
|
|
230
|
-
export
|
|
246
|
+
export interface RadarLocationPermissionStatusCallback {
|
|
247
|
+
(status: RadarLocationPermissionStatus): void;
|
|
248
|
+
}
|
|
249
|
+
export type RadarListenerCallback = RadarEventUpdateCallback | RadarLocationUpdateCallback | RadarClientLocationUpdateCallback | RadarErrorCallback | RadarLogUpdateCallback | RadarLocationPermissionStatusCallback;
|
|
231
250
|
export type RadarPermissionsStatus = "GRANTED_FOREGROUND" | "GRANTED_BACKGROUND" | "DENIED" | "NOT_DETERMINED" | "UNKNOWN";
|
|
232
251
|
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";
|
|
233
|
-
export type RadarEventChannel = "clientLocation" | "location" | "error" | "events" | "log" | "token";
|
|
252
|
+
export type RadarEventChannel = "clientLocation" | "location" | "error" | "events" | "log" | "token" | "locationPermissionStatus";
|
|
234
253
|
export type RadarLogLevel = "info" | "debug" | "warning" | "error" | "none";
|
|
235
254
|
export interface RadarRouteMatrix {
|
|
236
255
|
status: string;
|
|
@@ -472,3 +491,24 @@ export interface RadarTrackingOptionsForegroundService {
|
|
|
472
491
|
iconColor?: string;
|
|
473
492
|
}
|
|
474
493
|
export type RadarTripStatus = "unknown" | "started" | "approaching" | "arrived" | "expired" | "completed" | "canceled";
|
|
494
|
+
export interface RadarLocationPermissionStatusAndroid {
|
|
495
|
+
status: LocationPermissionState;
|
|
496
|
+
foregroundPermissionResult: boolean;
|
|
497
|
+
backgroundPermissionResult: boolean;
|
|
498
|
+
shouldShowRequestPermissionRationaleFG: boolean;
|
|
499
|
+
shouldShowRequestPermissionRationaleBG: boolean;
|
|
500
|
+
previouslyDeniedForeground: boolean;
|
|
501
|
+
inLocationPopup: boolean;
|
|
502
|
+
approximatePermissionResult: boolean;
|
|
503
|
+
previouslyDeniedBackground: boolean;
|
|
504
|
+
}
|
|
505
|
+
export interface RadarLocationPermissionStatusIOS {
|
|
506
|
+
status: LocationPermissionState;
|
|
507
|
+
locationManagerStatus: LocationManagerStatus;
|
|
508
|
+
backgroundPopupAvailable: boolean;
|
|
509
|
+
inForegroundPopup: boolean;
|
|
510
|
+
userRejectedBackgroundPermission: boolean;
|
|
511
|
+
}
|
|
512
|
+
export type RadarLocationPermissionStatus = RadarLocationPermissionStatusAndroid | RadarLocationPermissionStatusIOS;
|
|
513
|
+
export type LocationPermissionState = "NO_PERMISSION_GRANTED" | "FOREGROUND_PERMISSION_GRANTED" | "APPROXIMATE_PERMISSION_GRANTED" | "FOREGROUND_PERMISSION_REJECTED_ONCE" | "FOREGROUND_PERMISSION_REJECTED" | "FOREGROUND_PERMISSION_PENDING" | "BACKGROUND_PERMISSION_GRANTED" | "BACKGROUND_PERMISSION_REJECTED" | "BACKGROUND_PERMISSION_REJECTED_ONCE" | "PERMISSION_RESTRICTED" | "UNKNOWN";
|
|
514
|
+
export type LocationManagerStatus = "NotDetermined" | "Restricted" | "Denied" | "AuthorizedAlways" | "AuthorizedWhenInUse" | "Unknown";
|
package/dist/src/index.native.js
CHANGED
|
@@ -39,7 +39,7 @@ const trackOnce = (options) => {
|
|
|
39
39
|
return react_native_1.NativeModules.RNRadar.trackOnce(backCompatibleOptions);
|
|
40
40
|
};
|
|
41
41
|
const trackVerified = (options) => react_native_1.NativeModules.RNRadar.trackVerified(options);
|
|
42
|
-
const
|
|
42
|
+
const getVerifiedLocationToken = () => react_native_1.NativeModules.RNRadar.getVerifiedLocationToken();
|
|
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();
|
|
@@ -63,8 +63,8 @@ const getContext = (location) => react_native_1.NativeModules.RNRadar.getContext
|
|
|
63
63
|
const searchPlaces = (options) => react_native_1.NativeModules.RNRadar.searchPlaces(options);
|
|
64
64
|
const searchGeofences = (options) => react_native_1.NativeModules.RNRadar.searchGeofences(options);
|
|
65
65
|
const autocomplete = (options) => react_native_1.NativeModules.RNRadar.autocomplete(options);
|
|
66
|
-
const geocode = (
|
|
67
|
-
const reverseGeocode = (
|
|
66
|
+
const geocode = (options) => react_native_1.NativeModules.RNRadar.geocode(options);
|
|
67
|
+
const reverseGeocode = (options) => react_native_1.NativeModules.RNRadar.reverseGeocode(options);
|
|
68
68
|
const ipGeocode = () => react_native_1.NativeModules.RNRadar.ipGeocode();
|
|
69
69
|
const getDistance = (options) => react_native_1.NativeModules.RNRadar.getDistance(options);
|
|
70
70
|
const getMatrix = (options) => react_native_1.NativeModules.RNRadar.getMatrix(options);
|
|
@@ -98,7 +98,7 @@ const Radar = {
|
|
|
98
98
|
getLocation,
|
|
99
99
|
trackOnce,
|
|
100
100
|
trackVerified,
|
|
101
|
-
|
|
101
|
+
getVerifiedLocationToken,
|
|
102
102
|
startTrackingEfficient,
|
|
103
103
|
startTrackingResponsive,
|
|
104
104
|
startTrackingContinuous,
|
package/ios/Cartfile.resolved
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "radarlabs/radar-sdk-ios" "3.
|
|
1
|
+
github "radarlabs/radar-sdk-ios" "3.13.1"
|
package/ios/RNRadar.m
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNRadar.h"
|
|
2
|
+
#include <Foundation/Foundation.h>
|
|
2
3
|
|
|
3
4
|
#import <CoreLocation/CoreLocation.h>
|
|
4
5
|
#import <React/RCTConvert.h>
|
|
@@ -23,6 +24,36 @@ RCT_EXPORT_MODULE();
|
|
|
23
24
|
return self;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
+ (NSDictionary *)mapLocationPermissionStatus:(NSDictionary *)status {
|
|
28
|
+
NSString *statusString = status[@"locationPermissionState"];
|
|
29
|
+
NSString *newStatusString;
|
|
30
|
+
|
|
31
|
+
if ([statusString isEqualToString:@"NoPermissionGranted"]) {
|
|
32
|
+
newStatusString = @"NO_PERMISSION_GRANTED";
|
|
33
|
+
} else if ([statusString isEqualToString:@"ForegroundPermissionGranted"]) {
|
|
34
|
+
newStatusString = @"FOREGROUND_PERMISSION_GRANTED";
|
|
35
|
+
} else if ([statusString isEqualToString:@"ForegroundPermissionRejected"]) {
|
|
36
|
+
newStatusString = @"FOREGROUND_PERMISSION_REJECTED";
|
|
37
|
+
} else if ([statusString isEqualToString:@"ForegroundPermissionPending"]) {
|
|
38
|
+
newStatusString = @"FOREGROUND_PERMISSION_PENDING";
|
|
39
|
+
} else if ([statusString isEqualToString:@"BackgroundPermissionGranted"]) {
|
|
40
|
+
newStatusString = @"BACKGROUND_PERMISSION_GRANTED";
|
|
41
|
+
} else if ([statusString isEqualToString:@"BackgroundPermissionRejected"]) {
|
|
42
|
+
newStatusString = @"BACKGROUND_PERMISSION_REJECTED";
|
|
43
|
+
} else if ([statusString isEqualToString:@"BackgroundPermissionPending"]) {
|
|
44
|
+
newStatusString = @"FOREGROUND_PERMISSION_PENDING";
|
|
45
|
+
} else if ([statusString isEqualToString:@"PermissionRestricted"]) {
|
|
46
|
+
newStatusString = @"PERMISSION_RESTRICTED";
|
|
47
|
+
} else {
|
|
48
|
+
newStatusString = @"UNKNOWN";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
NSMutableDictionary *newStatus = [status mutableCopy];
|
|
52
|
+
[newStatus removeObjectForKey:@"locationPermissionState"];
|
|
53
|
+
[newStatus setValue:newStatusString forKey:@"status"];
|
|
54
|
+
return newStatus;
|
|
55
|
+
}
|
|
56
|
+
|
|
26
57
|
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
|
|
27
58
|
if (permissionsRequestResolver) {
|
|
28
59
|
[self getPermissionsStatusWithResolver:permissionsRequestResolver rejecter:nil];
|
|
@@ -92,15 +123,21 @@ RCT_EXPORT_MODULE();
|
|
|
92
123
|
}
|
|
93
124
|
}
|
|
94
125
|
|
|
95
|
-
- (void)didUpdateToken:(
|
|
126
|
+
- (void)didUpdateToken:(RadarVerifiedLocationToken *)token {
|
|
127
|
+
if (hasListeners) {
|
|
128
|
+
[self sendEventWithName:@"token" body:[token dictionaryValue]];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
- (void)didUpdateLocationPermissionStatus:(RadarLocationPermissionStatus *)status {
|
|
96
133
|
if (hasListeners) {
|
|
97
|
-
[self sendEventWithName:@"
|
|
134
|
+
[self sendEventWithName:@"locationPermissionStatus" body:[RNRadar mapLocationPermissionStatus:[status dictionaryValue]]];
|
|
98
135
|
}
|
|
99
136
|
}
|
|
100
137
|
|
|
101
138
|
RCT_EXPORT_METHOD(initialize:(NSString *)publishableKey fraud:(BOOL)fraud) {
|
|
102
139
|
[[NSUserDefaults standardUserDefaults] setObject:@"ReactNative" forKey:@"radar-xPlatformSDKType"];
|
|
103
|
-
[[NSUserDefaults standardUserDefaults] setObject:@"3.
|
|
140
|
+
[[NSUserDefaults standardUserDefaults] setObject:@"3.12.0" forKey:@"radar-xPlatformSDKVersion"];
|
|
104
141
|
[Radar initializeWithPublishableKey:publishableKey];
|
|
105
142
|
}
|
|
106
143
|
|
|
@@ -315,20 +352,13 @@ RCT_EXPORT_METHOD(trackVerified:(NSDictionary *)optionsDict resolve:(RCTPromiseR
|
|
|
315
352
|
__block RCTPromiseResolveBlock resolver = resolve;
|
|
316
353
|
__block RCTPromiseRejectBlock rejecter = reject;
|
|
317
354
|
|
|
318
|
-
|
|
355
|
+
RadarTrackVerifiedCompletionHandler completionHandler = ^(RadarStatus status, RadarVerifiedLocationToken * _Nullable token) {
|
|
319
356
|
if (status == RadarStatusSuccess && resolver) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
if (events) {
|
|
326
|
-
[dict setObject:[RadarEvent arrayForEvents:events] forKey:@"events"];
|
|
357
|
+
if (token != nil) {
|
|
358
|
+
resolver([token dictionaryValue]);
|
|
359
|
+
} else {
|
|
360
|
+
resolver(nil);
|
|
327
361
|
}
|
|
328
|
-
if (user) {
|
|
329
|
-
[dict setObject:[user dictionaryValue] forKey:@"user"];
|
|
330
|
-
}
|
|
331
|
-
resolver(dict);
|
|
332
362
|
} else if (rejecter) {
|
|
333
363
|
rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil);
|
|
334
364
|
}
|
|
@@ -339,26 +369,17 @@ RCT_EXPORT_METHOD(trackVerified:(NSDictionary *)optionsDict resolve:(RCTPromiseR
|
|
|
339
369
|
[Radar trackVerifiedWithBeacons:beacons completionHandler:completionHandler];
|
|
340
370
|
}
|
|
341
371
|
|
|
342
|
-
RCT_EXPORT_METHOD(
|
|
343
|
-
BOOL beacons = NO;
|
|
344
|
-
if (optionsDict != nil) {
|
|
345
|
-
NSNumber *beaconsNumber = optionsDict[@"beacons"];
|
|
346
|
-
if (beaconsNumber != nil && [beaconsNumber isKindOfClass:[NSNumber class]]) {
|
|
347
|
-
beacons = [beaconsNumber boolValue];
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
372
|
+
RCT_EXPORT_METHOD(getVerifiedLocationToken:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
351
373
|
__block RCTPromiseResolveBlock resolver = resolve;
|
|
352
374
|
__block RCTPromiseRejectBlock rejecter = reject;
|
|
353
375
|
|
|
354
|
-
|
|
376
|
+
RadarTrackVerifiedCompletionHandler completionHandler = ^(RadarStatus status, RadarVerifiedLocationToken * _Nullable token) {
|
|
355
377
|
if (status == RadarStatusSuccess && resolver) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
378
|
+
if (token != nil) {
|
|
379
|
+
resolver([token dictionaryValue]);
|
|
380
|
+
} else {
|
|
381
|
+
resolver(nil);
|
|
360
382
|
}
|
|
361
|
-
resolver(dict);
|
|
362
383
|
} else if (rejecter) {
|
|
363
384
|
rejecter([Radar stringForStatus:status], [Radar stringForStatus:status], nil);
|
|
364
385
|
}
|
|
@@ -366,7 +387,7 @@ RCT_EXPORT_METHOD(trackVerifiedToken:(NSDictionary *)optionsDict resolve:(RCTPro
|
|
|
366
387
|
rejecter = nil;
|
|
367
388
|
};
|
|
368
389
|
|
|
369
|
-
[Radar
|
|
390
|
+
[Radar getVerifiedLocationToken:completionHandler];
|
|
370
391
|
}
|
|
371
392
|
|
|
372
393
|
RCT_EXPORT_METHOD(startTrackingEfficient) {
|
|
@@ -406,7 +427,7 @@ RCT_EXPORT_METHOD(startTrackingVerified:(NSDictionary *)optionsDict) {
|
|
|
406
427
|
}
|
|
407
428
|
}
|
|
408
429
|
|
|
409
|
-
[Radar
|
|
430
|
+
[Radar startTrackingVerifiedWithInterval:interval beacons:beacons];
|
|
410
431
|
}
|
|
411
432
|
|
|
412
433
|
RCT_EXPORT_METHOD(mockTracking:(NSDictionary *)optionsDict) {
|
|
@@ -494,7 +515,11 @@ RCT_EXPORT_METHOD(getTripOptions:(RCTPromiseResolveBlock)resolve reject:(RCTProm
|
|
|
494
515
|
}
|
|
495
516
|
|
|
496
517
|
RadarTripOptions* options = [Radar getTripOptions];
|
|
497
|
-
|
|
518
|
+
if (options != nil) {
|
|
519
|
+
resolve([options dictionaryValue]);
|
|
520
|
+
} else {
|
|
521
|
+
resolve(nil);
|
|
522
|
+
}
|
|
498
523
|
}
|
|
499
524
|
|
|
500
525
|
RCT_EXPORT_METHOD(startTrip:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
@@ -873,11 +898,23 @@ RCT_EXPORT_METHOD(autocomplete:(NSDictionary *)optionsDict resolve:(RCTPromiseRe
|
|
|
873
898
|
}];
|
|
874
899
|
}
|
|
875
900
|
|
|
876
|
-
RCT_EXPORT_METHOD(geocode:(
|
|
901
|
+
RCT_EXPORT_METHOD(geocode:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
902
|
+
if (optionsDict[@"address"] == nil) {
|
|
903
|
+
if (reject) {
|
|
904
|
+
reject([Radar stringForStatus:RadarStatusErrorBadRequest], [Radar stringForStatus:RadarStatusErrorBadRequest], nil);
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
NSString *query = optionsDict[@"address"];
|
|
911
|
+
NSArray *layers = optionsDict[@"layers"];
|
|
912
|
+
NSArray *countries = optionsDict[@"countries"];
|
|
913
|
+
|
|
877
914
|
__block RCTPromiseResolveBlock resolver = resolve;
|
|
878
915
|
__block RCTPromiseRejectBlock rejecter = reject;
|
|
879
916
|
|
|
880
|
-
[Radar geocodeAddress:query completionHandler:^(RadarStatus status, NSArray<RadarAddress *> * _Nullable addresses) {
|
|
917
|
+
[Radar geocodeAddress:query layers:layers countries:countries completionHandler:^(RadarStatus status, NSArray<RadarAddress *> * _Nullable addresses) {
|
|
881
918
|
if (status == RadarStatusSuccess && resolver) {
|
|
882
919
|
NSMutableDictionary *dict = [NSMutableDictionary new];
|
|
883
920
|
[dict setObject:[Radar stringForStatus:status] forKey:@"status"];
|
|
@@ -893,13 +930,13 @@ RCT_EXPORT_METHOD(geocode:(NSString *)query resolve:(RCTPromiseResolveBlock)reso
|
|
|
893
930
|
}];
|
|
894
931
|
}
|
|
895
932
|
|
|
896
|
-
RCT_EXPORT_METHOD(reverseGeocode:(NSDictionary *)
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
933
|
+
RCT_EXPORT_METHOD(reverseGeocode:(NSDictionary *)optionsDict resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
934
|
+
NSDictionary *locationDict = nil;
|
|
935
|
+
NSArray *layers = nil;
|
|
936
|
+
|
|
937
|
+
if (optionsDict != nil) {
|
|
938
|
+
locationDict = optionsDict[@"location"];
|
|
939
|
+
layers = optionsDict[@"layers"];
|
|
903
940
|
}
|
|
904
941
|
|
|
905
942
|
__block RCTPromiseResolveBlock resolver = resolve;
|
|
@@ -920,10 +957,18 @@ RCT_EXPORT_METHOD(reverseGeocode:(NSDictionary *)locationDict resolve:(RCTPromis
|
|
|
920
957
|
rejecter = nil;
|
|
921
958
|
};
|
|
922
959
|
|
|
923
|
-
if (
|
|
924
|
-
[
|
|
960
|
+
if (locationDict != nil && [locationDict isKindOfClass:[NSDictionary class]]) {
|
|
961
|
+
double latitude = [RCTConvert double:locationDict[@"latitude"]];
|
|
962
|
+
double longitude = [RCTConvert double:locationDict[@"longitude"]];
|
|
963
|
+
NSDate *timestamp = [NSDate new];
|
|
964
|
+
CLLocation *location = [[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude)
|
|
965
|
+
altitude:-1
|
|
966
|
+
horizontalAccuracy:5
|
|
967
|
+
verticalAccuracy:-1
|
|
968
|
+
timestamp:timestamp];
|
|
969
|
+
[Radar reverseGeocodeLocation:location layers:layers completionHandler:completionHandler];
|
|
925
970
|
} else {
|
|
926
|
-
[Radar
|
|
971
|
+
[Radar reverseGeocodeWithLayers:layers completionHandler:completionHandler];
|
|
927
972
|
}
|
|
928
973
|
}
|
|
929
974
|
|
|
@@ -1137,4 +1182,22 @@ RCT_EXPORT_METHOD(logConversion:(NSDictionary *)optionsDict resolve:(RCTPromiseR
|
|
|
1137
1182
|
[Radar logConversionWithName:name revenue:revenue metadata:metadata completionHandler:completionHandler];
|
|
1138
1183
|
}
|
|
1139
1184
|
}
|
|
1185
|
+
|
|
1186
|
+
RCT_EXPORT_METHOD(requestForegroundLocationPermission) {
|
|
1187
|
+
[Radar requestForegroundLocationPermission];
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
RCT_EXPORT_METHOD(requestBackgroundLocationPermission) {
|
|
1191
|
+
[Radar requestBackgroundLocationPermission];
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
RCT_EXPORT_METHOD(getLocationPermissionStatus:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
1195
|
+
RadarLocationPermissionStatus* status = [Radar getLocationPermissionStatus];
|
|
1196
|
+
resolve([RNRadar mapLocationPermissionStatus:[status dictionaryValue]]);
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
RCT_EXPORT_METHOD(openAppSettings) {
|
|
1200
|
+
[Radar openAppSettings];
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1140
1203
|
@end
|
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.
|
|
6
|
+
"version": "3.12.0",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"android",
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"reporters": [
|
|
28
28
|
"default",
|
|
29
29
|
"jest-junit"
|
|
30
|
+
],
|
|
31
|
+
"modulePathIgnorePatterns": [
|
|
32
|
+
"example",
|
|
33
|
+
"example2"
|
|
30
34
|
]
|
|
31
35
|
},
|
|
32
36
|
"peerDependencies": {
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
RadarContextCallback,
|
|
5
5
|
RadarAddressCallback,
|
|
6
6
|
RadarEventChannel,
|
|
7
|
+
RadarGeocodeOptions,
|
|
7
8
|
RadarGetDistanceOptions,
|
|
8
9
|
RadarLocationCallback,
|
|
9
10
|
RadarLogConversionCallback,
|
|
@@ -12,6 +13,7 @@ import {
|
|
|
12
13
|
RadarMockTrackingOptions,
|
|
13
14
|
RadarNotificationOptions,
|
|
14
15
|
RadarPermissionsStatus,
|
|
16
|
+
RadarReverseGeocodeOptions,
|
|
15
17
|
RadarRouteCallback,
|
|
16
18
|
RadarRouteMatrix,
|
|
17
19
|
RadarSearchGeofencesCallback,
|
|
@@ -21,7 +23,7 @@ import {
|
|
|
21
23
|
RadarStartTripOptions,
|
|
22
24
|
RadarTrackCallback,
|
|
23
25
|
RadarTrackOnceOptions,
|
|
24
|
-
|
|
26
|
+
RadarTrackVerifiedCallback,
|
|
25
27
|
RadarTrackingOptions,
|
|
26
28
|
RadarTrackingOptionsDesiredAccuracy,
|
|
27
29
|
RadarTrackingOptionsForegroundService,
|
|
@@ -34,6 +36,7 @@ import {
|
|
|
34
36
|
RadarGetMatrixOptions,
|
|
35
37
|
RadarMetadata,
|
|
36
38
|
RadarIPGeocodeCallback,
|
|
39
|
+
RadarLocationPermissionStatus,
|
|
37
40
|
} from "./types";
|
|
38
41
|
|
|
39
42
|
export interface RadarNativeInterface {
|
|
@@ -54,8 +57,8 @@ export interface RadarNativeInterface {
|
|
|
54
57
|
trackOnce: (
|
|
55
58
|
options?: RadarTrackOnceOptions | Location
|
|
56
59
|
) => Promise<RadarTrackCallback>;
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
trackVerified: (options?: RadarTrackVerifiedOptions) => Promise<RadarTrackVerifiedCallback>;
|
|
61
|
+
getVerifiedLocationToken: () => Promise<RadarTrackVerifiedCallback>;
|
|
59
62
|
startTrackingEfficient: () => void;
|
|
60
63
|
startTrackingResponsive: () => void;
|
|
61
64
|
startTrackingContinuous: () => void;
|
|
@@ -87,8 +90,8 @@ export interface RadarNativeInterface {
|
|
|
87
90
|
autocomplete: (
|
|
88
91
|
options: RadarAutocompleteOptions
|
|
89
92
|
) => Promise<RadarAddressCallback>;
|
|
90
|
-
geocode: (
|
|
91
|
-
reverseGeocode: (
|
|
93
|
+
geocode: (options: RadarGeocodeOptions) => Promise<RadarAddressCallback>;
|
|
94
|
+
reverseGeocode: (options?: RadarReverseGeocodeOptions) => Promise<RadarAddressCallback>;
|
|
92
95
|
ipGeocode: () => Promise<RadarIPGeocodeCallback>;
|
|
93
96
|
getDistance: (option: RadarGetDistanceOptions) => Promise<RadarRouteCallback>;
|
|
94
97
|
getMatrix: (option: RadarGetMatrixOptions) => Promise<RadarRouteMatrix>;
|
package/src/@types/types.ts
CHANGED
|
@@ -195,11 +195,19 @@ export interface RadarMockTrackingOptions {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
export interface RadarVerifiedTrackingOptions {
|
|
198
|
-
token?: boolean;
|
|
199
198
|
interval?: number;
|
|
200
199
|
beacons?: boolean;
|
|
201
200
|
}
|
|
202
201
|
|
|
202
|
+
export interface RadarVerifiedLocationToken {
|
|
203
|
+
user: RadarUser;
|
|
204
|
+
events: RadarEvent[];
|
|
205
|
+
token: string;
|
|
206
|
+
expiresAt: Date;
|
|
207
|
+
expiresIn: number;
|
|
208
|
+
passed: boolean;
|
|
209
|
+
}
|
|
210
|
+
|
|
203
211
|
export interface RadarGetDistanceOptions {
|
|
204
212
|
origin?: Location;
|
|
205
213
|
destination?: Location;
|
|
@@ -266,6 +274,17 @@ export interface RadarAutocompleteOptions {
|
|
|
266
274
|
mailable?: boolean;
|
|
267
275
|
}
|
|
268
276
|
|
|
277
|
+
export interface RadarGeocodeOptions {
|
|
278
|
+
address: string;
|
|
279
|
+
layers?: string[];
|
|
280
|
+
countries?: string[];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface RadarReverseGeocodeOptions {
|
|
284
|
+
location?: Location;
|
|
285
|
+
layers?: string[];
|
|
286
|
+
}
|
|
287
|
+
|
|
269
288
|
export interface RadarNotificationOptions {
|
|
270
289
|
iconString?: string;
|
|
271
290
|
iconColor?: string;
|
|
@@ -361,9 +380,9 @@ export interface RadarLogConversionCallback {
|
|
|
361
380
|
event?: RadarEvent;
|
|
362
381
|
}
|
|
363
382
|
|
|
364
|
-
export interface
|
|
383
|
+
export interface RadarTrackVerifiedCallback {
|
|
365
384
|
status: string;
|
|
366
|
-
token?:
|
|
385
|
+
token?: RadarVerifiedLocationToken;
|
|
367
386
|
}
|
|
368
387
|
|
|
369
388
|
export interface RadarEventUpdate {
|
|
@@ -402,12 +421,17 @@ export interface RadarLogUpdateCallback {
|
|
|
402
421
|
(status: string): void;
|
|
403
422
|
}
|
|
404
423
|
|
|
424
|
+
export interface RadarLocationPermissionStatusCallback {
|
|
425
|
+
(status: RadarLocationPermissionStatus): void;
|
|
426
|
+
}
|
|
427
|
+
|
|
405
428
|
export type RadarListenerCallback =
|
|
406
429
|
| RadarEventUpdateCallback
|
|
407
430
|
| RadarLocationUpdateCallback
|
|
408
431
|
| RadarClientLocationUpdateCallback
|
|
409
432
|
| RadarErrorCallback
|
|
410
|
-
| RadarLogUpdateCallback
|
|
433
|
+
| RadarLogUpdateCallback
|
|
434
|
+
| RadarLocationPermissionStatusCallback;
|
|
411
435
|
|
|
412
436
|
export type RadarPermissionsStatus =
|
|
413
437
|
| "GRANTED_FOREGROUND"
|
|
@@ -430,7 +454,7 @@ export type RadarLocationSource =
|
|
|
430
454
|
| "BEACON_EXIT"
|
|
431
455
|
| "UNKNOWN";
|
|
432
456
|
|
|
433
|
-
export type RadarEventChannel = "clientLocation" | "location" | "error" | "events" | "log" | "token";
|
|
457
|
+
export type RadarEventChannel = "clientLocation" | "location" | "error" | "events" | "log" | "token" | "locationPermissionStatus";
|
|
434
458
|
|
|
435
459
|
export type RadarLogLevel = "info" | "debug" | "warning" | "error" | "none";
|
|
436
460
|
|
|
@@ -759,3 +783,47 @@ export type RadarTripStatus =
|
|
|
759
783
|
| "expired"
|
|
760
784
|
| "completed"
|
|
761
785
|
| "canceled";
|
|
786
|
+
|
|
787
|
+
export interface RadarLocationPermissionStatusAndroid {
|
|
788
|
+
status: LocationPermissionState;
|
|
789
|
+
foregroundPermissionResult: boolean;
|
|
790
|
+
backgroundPermissionResult: boolean;
|
|
791
|
+
shouldShowRequestPermissionRationaleFG: boolean;
|
|
792
|
+
shouldShowRequestPermissionRationaleBG: boolean;
|
|
793
|
+
previouslyDeniedForeground: boolean;
|
|
794
|
+
inLocationPopup: boolean;
|
|
795
|
+
approximatePermissionResult: boolean;
|
|
796
|
+
previouslyDeniedBackground: boolean;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
export interface RadarLocationPermissionStatusIOS {
|
|
800
|
+
status: LocationPermissionState;
|
|
801
|
+
locationManagerStatus: LocationManagerStatus;
|
|
802
|
+
backgroundPopupAvailable: boolean;
|
|
803
|
+
inForegroundPopup: boolean;
|
|
804
|
+
userRejectedBackgroundPermission: boolean;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
export type RadarLocationPermissionStatus =
|
|
808
|
+
RadarLocationPermissionStatusAndroid | RadarLocationPermissionStatusIOS
|
|
809
|
+
|
|
810
|
+
export type LocationPermissionState =
|
|
811
|
+
| "NO_PERMISSION_GRANTED"
|
|
812
|
+
| "FOREGROUND_PERMISSION_GRANTED"
|
|
813
|
+
| "APPROXIMATE_PERMISSION_GRANTED"
|
|
814
|
+
| "FOREGROUND_PERMISSION_REJECTED_ONCE"
|
|
815
|
+
| "FOREGROUND_PERMISSION_REJECTED"
|
|
816
|
+
| "FOREGROUND_PERMISSION_PENDING"
|
|
817
|
+
| "BACKGROUND_PERMISSION_GRANTED"
|
|
818
|
+
| "BACKGROUND_PERMISSION_REJECTED"
|
|
819
|
+
| "BACKGROUND_PERMISSION_REJECTED_ONCE"
|
|
820
|
+
| "PERMISSION_RESTRICTED"
|
|
821
|
+
| "UNKNOWN";
|
|
822
|
+
|
|
823
|
+
export type LocationManagerStatus =
|
|
824
|
+
| "NotDetermined"
|
|
825
|
+
| "Restricted"
|
|
826
|
+
| "Denied"
|
|
827
|
+
| "AuthorizedAlways"
|
|
828
|
+
| "AuthorizedWhenInUse"
|
|
829
|
+
| "Unknown";
|
package/src/index.native.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
RadarContextCallback,
|
|
8
8
|
RadarAddressCallback,
|
|
9
9
|
RadarEventChannel,
|
|
10
|
+
RadarGeocodeOptions,
|
|
10
11
|
RadarGetDistanceOptions,
|
|
11
12
|
RadarLocationCallback,
|
|
12
13
|
RadarLogConversionCallback,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
RadarMockTrackingOptions,
|
|
16
17
|
RadarNotificationOptions,
|
|
17
18
|
RadarPermissionsStatus,
|
|
19
|
+
RadarReverseGeocodeOptions,
|
|
18
20
|
RadarRouteCallback,
|
|
19
21
|
RadarRouteMatrix,
|
|
20
22
|
RadarSearchGeofencesCallback,
|
|
@@ -24,7 +26,6 @@ import {
|
|
|
24
26
|
RadarStartTripOptions,
|
|
25
27
|
RadarTrackCallback,
|
|
26
28
|
RadarTrackOnceOptions,
|
|
27
|
-
RadarTrackTokenCallback,
|
|
28
29
|
RadarTrackingOptions,
|
|
29
30
|
RadarTrackingOptionsDesiredAccuracy,
|
|
30
31
|
RadarTrackingOptionsForegroundService,
|
|
@@ -37,6 +38,7 @@ import {
|
|
|
37
38
|
RadarMetadata,
|
|
38
39
|
RadarIPGeocodeCallback,
|
|
39
40
|
RadarTrackVerifiedOptions,
|
|
41
|
+
RadarTrackVerifiedCallback,
|
|
40
42
|
} from "./@types/types";
|
|
41
43
|
|
|
42
44
|
if (
|
|
@@ -106,11 +108,11 @@ const trackOnce = (
|
|
|
106
108
|
return NativeModules.RNRadar.trackOnce(backCompatibleOptions);
|
|
107
109
|
};
|
|
108
110
|
|
|
109
|
-
const trackVerified = (options?: RadarTrackVerifiedOptions): Promise<
|
|
111
|
+
const trackVerified = (options?: RadarTrackVerifiedOptions): Promise<RadarTrackVerifiedCallback> =>
|
|
110
112
|
NativeModules.RNRadar.trackVerified(options);
|
|
111
113
|
|
|
112
|
-
const
|
|
113
|
-
NativeModules.RNRadar.
|
|
114
|
+
const getVerifiedLocationToken = (): Promise<RadarTrackVerifiedCallback> =>
|
|
115
|
+
NativeModules.RNRadar.getVerifiedLocationToken();
|
|
114
116
|
|
|
115
117
|
const startTrackingEfficient = (): void =>
|
|
116
118
|
NativeModules.RNRadar.startTrackingEfficient();
|
|
@@ -187,11 +189,11 @@ const autocomplete = (
|
|
|
187
189
|
options: RadarAutocompleteOptions
|
|
188
190
|
): Promise<RadarAddressCallback> => NativeModules.RNRadar.autocomplete(options);
|
|
189
191
|
|
|
190
|
-
const geocode = (
|
|
191
|
-
NativeModules.RNRadar.geocode(
|
|
192
|
+
const geocode = (options: RadarGeocodeOptions): Promise<RadarAddressCallback> =>
|
|
193
|
+
NativeModules.RNRadar.geocode(options);
|
|
192
194
|
|
|
193
|
-
const reverseGeocode = (
|
|
194
|
-
NativeModules.RNRadar.reverseGeocode(
|
|
195
|
+
const reverseGeocode = (options?: RadarReverseGeocodeOptions): Promise<RadarAddressCallback> =>
|
|
196
|
+
NativeModules.RNRadar.reverseGeocode(options);
|
|
195
197
|
|
|
196
198
|
const ipGeocode = (): Promise<RadarIPGeocodeCallback> =>
|
|
197
199
|
NativeModules.RNRadar.ipGeocode();
|
|
@@ -244,7 +246,7 @@ const Radar: RadarNativeInterface = {
|
|
|
244
246
|
getLocation,
|
|
245
247
|
trackOnce,
|
|
246
248
|
trackVerified,
|
|
247
|
-
|
|
249
|
+
getVerifiedLocationToken,
|
|
248
250
|
startTrackingEfficient,
|
|
249
251
|
startTrackingResponsive,
|
|
250
252
|
startTrackingContinuous,
|