react-native-radar 3.9.1 → 3.10.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -1
- package/dist/package.json +79 -0
- package/dist/src/@types/RadarNativeInterface.d.ts +51 -0
- package/dist/src/@types/RadarNativeInterface.js +2 -0
- package/dist/src/@types/types.d.ts +379 -0
- package/dist/src/@types/types.js +16 -0
- package/dist/src/helpers.d.ts +2 -0
- package/dist/src/helpers.js +11 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.native.d.ts +3 -0
- package/dist/src/index.native.js +136 -0
- package/dist/src/index.web.d.ts +73 -0
- package/dist/src/index.web.js +385 -0
- package/dist/src/ui/autocomplete.d.ts +4 -0
- package/dist/src/ui/autocomplete.js +213 -0
- package/dist/src/ui/images.d.ts +5 -0
- package/dist/src/ui/images.js +8 -0
- package/dist/src/ui/map.d.ts +5 -0
- package/dist/src/ui/map.js +112 -0
- package/dist/src/ui/styles.d.ts +2 -0
- package/dist/src/ui/styles.js +125 -0
- package/package.json +14 -8
- package/src/@types/RadarNativeInterface.ts +96 -0
- package/src/@types/types.ts +489 -0
- package/src/index.native.ts +272 -0
- package/src/index.ts +21 -0
- package/{js → src}/index.web.js +1 -1
- package/{js → src}/ui/autocomplete.jsx +3 -3
- package/js/index.js +0 -12
- package/js/index.native.js +0 -263
- /package/{js → src}/helpers.js +0 -0
- /package/{js → src}/ui/back.png +0 -0
- /package/{js → src}/ui/close.png +0 -0
- /package/{js → src}/ui/images.js +0 -0
- /package/{js → src}/ui/map-logo.png +0 -0
- /package/{js → src}/ui/map.jsx +0 -0
- /package/{js → src}/ui/marker.png +0 -0
- /package/{js → src}/ui/radar-logo.png +0 -0
- /package/{js → src}/ui/search.png +0 -0
- /package/{js → src}/ui/styles.js +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_native_1 = require("react-native");
|
|
4
|
+
const package_json_1 = require("../package.json");
|
|
5
|
+
if (!react_native_1.NativeModules.RNRadar &&
|
|
6
|
+
(react_native_1.Platform.OS === "ios" || react_native_1.Platform.OS === "android")) {
|
|
7
|
+
throw new Error("NativeModules.RNRadar is undefined");
|
|
8
|
+
}
|
|
9
|
+
const eventEmitter = new react_native_1.NativeEventEmitter(react_native_1.NativeModules.RNRadar);
|
|
10
|
+
const initialize = (publishableKey, fraud = false) => {
|
|
11
|
+
react_native_1.NativeModules.RNRadar.initialize(publishableKey, fraud);
|
|
12
|
+
};
|
|
13
|
+
const setLogLevel = (level) => {
|
|
14
|
+
react_native_1.NativeModules.RNRadar.setLogLevel(level);
|
|
15
|
+
};
|
|
16
|
+
const setUserId = (userId) => {
|
|
17
|
+
react_native_1.NativeModules.RNRadar.setUserId(userId);
|
|
18
|
+
};
|
|
19
|
+
const getUserId = () => react_native_1.NativeModules.RNRadar.getUserId();
|
|
20
|
+
const setDescription = (description) => {
|
|
21
|
+
react_native_1.NativeModules.RNRadar.setDescription(description);
|
|
22
|
+
};
|
|
23
|
+
const getDescription = () => react_native_1.NativeModules.RNRadar.getDescription();
|
|
24
|
+
const setMetadata = (metadata) => {
|
|
25
|
+
react_native_1.NativeModules.RNRadar.setMetadata(metadata);
|
|
26
|
+
};
|
|
27
|
+
const getMetadata = () => react_native_1.NativeModules.RNRadar.getMetadata();
|
|
28
|
+
const setAnonymousTrackingEnabled = (enabled) => react_native_1.NativeModules.RNRadar.setAnonymousTrackingEnabled(enabled);
|
|
29
|
+
const getPermissionsStatus = () => react_native_1.NativeModules.RNRadar.getPermissionsStatus();
|
|
30
|
+
const requestPermissions = (background) => react_native_1.NativeModules.RNRadar.requestPermissions(background);
|
|
31
|
+
const getLocation = (desiredAccuracy) => react_native_1.NativeModules.RNRadar.getLocation(desiredAccuracy);
|
|
32
|
+
const trackOnce = (options) => {
|
|
33
|
+
let backCompatibleOptions = options;
|
|
34
|
+
if (options && "latitude" in options) {
|
|
35
|
+
backCompatibleOptions = {
|
|
36
|
+
location: {
|
|
37
|
+
...options,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return react_native_1.NativeModules.RNRadar.trackOnce(backCompatibleOptions);
|
|
42
|
+
};
|
|
43
|
+
const trackVerified = () => react_native_1.NativeModules.RNRadar.trackVerified();
|
|
44
|
+
const trackVerifiedToken = () => react_native_1.NativeModules.RNRadar.trackVerifiedToken();
|
|
45
|
+
const startTrackingEfficient = () => react_native_1.NativeModules.RNRadar.startTrackingEfficient();
|
|
46
|
+
const startTrackingResponsive = () => react_native_1.NativeModules.RNRadar.startTrackingResponsive();
|
|
47
|
+
const startTrackingContinuous = () => react_native_1.NativeModules.RNRadar.startTrackingContinuous();
|
|
48
|
+
const startTrackingCustom = (options) => react_native_1.NativeModules.RNRadar.startTrackingCustom(options);
|
|
49
|
+
const mockTracking = (options) => react_native_1.NativeModules.RNRadar.mockTracking(options);
|
|
50
|
+
const stopTracking = () => react_native_1.NativeModules.RNRadar.stopTracking();
|
|
51
|
+
const getTrackingOptions = () => react_native_1.NativeModules.RNRadar.getTrackingOptions();
|
|
52
|
+
const isUsingRemoteTrackingOptions = () => react_native_1.NativeModules.RNRadar.isUsingRemoteTrackingOptions();
|
|
53
|
+
const isTracking = () => react_native_1.NativeModules.RNRadar.isTracking();
|
|
54
|
+
const setForegroundServiceOptions = (options) => react_native_1.NativeModules.RNRadar.setForegroundServiceOptions(options);
|
|
55
|
+
const setNotificationOptions = (options) => react_native_1.NativeModules.RNRadar.setNotificationOptions(options);
|
|
56
|
+
const getTripOptions = () => react_native_1.NativeModules.RNRadar.getTripOptions();
|
|
57
|
+
const startTrip = (options) => react_native_1.NativeModules.RNRadar.startTrip(options);
|
|
58
|
+
const completeTrip = () => react_native_1.NativeModules.RNRadar.completeTrip();
|
|
59
|
+
const cancelTrip = () => react_native_1.NativeModules.RNRadar.cancelTrip();
|
|
60
|
+
const updateTrip = (options) => react_native_1.NativeModules.RNRadar.updateTrip(options);
|
|
61
|
+
const acceptEvent = (eventId, verifiedPlaceId) => react_native_1.NativeModules.RNRadar.acceptEvent(eventId, verifiedPlaceId);
|
|
62
|
+
const rejectEvent = (eventId) => react_native_1.NativeModules.RNRadar.rejectEvent(eventId);
|
|
63
|
+
const getContext = (location) => react_native_1.NativeModules.RNRadar.getContext(location);
|
|
64
|
+
const searchPlaces = (options) => react_native_1.NativeModules.RNRadar.searchPlaces(options);
|
|
65
|
+
const searchGeofences = (options) => react_native_1.NativeModules.RNRadar.searchGeofences(options);
|
|
66
|
+
const autocomplete = (options) => react_native_1.NativeModules.RNRadar.autocomplete(options);
|
|
67
|
+
const geocode = (address) => react_native_1.NativeModules.RNRadar.geocode(address);
|
|
68
|
+
const reverseGeocode = (location) => react_native_1.NativeModules.RNRadar.reverseGeocode(location);
|
|
69
|
+
const ipGeocode = () => react_native_1.NativeModules.RNRadar.ipGeocode();
|
|
70
|
+
const getDistance = (options) => react_native_1.NativeModules.RNRadar.getDistance(options);
|
|
71
|
+
const getMatrix = (options) => react_native_1.NativeModules.RNRadar.getMatrix(options);
|
|
72
|
+
const logConversion = (options) => react_native_1.NativeModules.RNRadar.logConversion(options);
|
|
73
|
+
const sendEvent = (name, metadata) => react_native_1.NativeModules.RNRadar.sendEvent(name, metadata);
|
|
74
|
+
const on = (event, callback) => eventEmitter.addListener(event, callback);
|
|
75
|
+
const off = (event, callback) => {
|
|
76
|
+
if (callback) {
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
eventEmitter.removeListener(event, callback);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
eventEmitter.removeAllListeners(event);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const nativeSdkVersion = () => react_native_1.NativeModules.RNRadar.nativeSdkVersion();
|
|
85
|
+
const rnSdkVersion = () => package_json_1.version;
|
|
86
|
+
const Radar = {
|
|
87
|
+
initialize,
|
|
88
|
+
setLogLevel,
|
|
89
|
+
setUserId,
|
|
90
|
+
getUserId,
|
|
91
|
+
setDescription,
|
|
92
|
+
getDescription,
|
|
93
|
+
setMetadata,
|
|
94
|
+
getMetadata,
|
|
95
|
+
setAnonymousTrackingEnabled,
|
|
96
|
+
isUsingRemoteTrackingOptions,
|
|
97
|
+
getPermissionsStatus,
|
|
98
|
+
requestPermissions,
|
|
99
|
+
getLocation,
|
|
100
|
+
trackOnce,
|
|
101
|
+
trackVerified,
|
|
102
|
+
trackVerifiedToken,
|
|
103
|
+
startTrackingEfficient,
|
|
104
|
+
startTrackingResponsive,
|
|
105
|
+
startTrackingContinuous,
|
|
106
|
+
startTrackingCustom,
|
|
107
|
+
mockTracking,
|
|
108
|
+
stopTracking,
|
|
109
|
+
isTracking,
|
|
110
|
+
getTrackingOptions,
|
|
111
|
+
setForegroundServiceOptions,
|
|
112
|
+
setNotificationOptions,
|
|
113
|
+
acceptEvent,
|
|
114
|
+
rejectEvent,
|
|
115
|
+
getTripOptions,
|
|
116
|
+
startTrip,
|
|
117
|
+
updateTrip,
|
|
118
|
+
completeTrip,
|
|
119
|
+
cancelTrip,
|
|
120
|
+
getContext,
|
|
121
|
+
searchPlaces,
|
|
122
|
+
searchGeofences,
|
|
123
|
+
autocomplete,
|
|
124
|
+
geocode,
|
|
125
|
+
reverseGeocode,
|
|
126
|
+
ipGeocode,
|
|
127
|
+
getDistance,
|
|
128
|
+
getMatrix,
|
|
129
|
+
logConversion,
|
|
130
|
+
sendEvent,
|
|
131
|
+
on,
|
|
132
|
+
off,
|
|
133
|
+
nativeSdkVersion,
|
|
134
|
+
rnSdkVersion,
|
|
135
|
+
};
|
|
136
|
+
exports.default = Radar;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export default Radar;
|
|
2
|
+
declare namespace Radar {
|
|
3
|
+
export { initialize };
|
|
4
|
+
export { setLogLevel };
|
|
5
|
+
export { setUserId };
|
|
6
|
+
export { setDescription };
|
|
7
|
+
export { setMetadata };
|
|
8
|
+
export { getPermissionsStatus };
|
|
9
|
+
export { requestPermissions };
|
|
10
|
+
export { getLocation };
|
|
11
|
+
export { trackOnce };
|
|
12
|
+
export { trackVerified };
|
|
13
|
+
export { trackVerifiedToken };
|
|
14
|
+
export { startTrackingEfficient };
|
|
15
|
+
export { startTrackingResponsive };
|
|
16
|
+
export { startTrackingContinuous };
|
|
17
|
+
export { startTrackingCustom };
|
|
18
|
+
export { mockTracking };
|
|
19
|
+
export { stopTracking };
|
|
20
|
+
export { setForegroundServiceOptions };
|
|
21
|
+
export { acceptEvent };
|
|
22
|
+
export { rejectEvent };
|
|
23
|
+
export { startTrip };
|
|
24
|
+
export { updateTrip };
|
|
25
|
+
export { completeTrip };
|
|
26
|
+
export { cancelTrip };
|
|
27
|
+
export { getContext };
|
|
28
|
+
export { searchPlaces };
|
|
29
|
+
export { searchGeofences };
|
|
30
|
+
export { autocomplete };
|
|
31
|
+
export { geocode };
|
|
32
|
+
export { reverseGeocode };
|
|
33
|
+
export { ipGeocode };
|
|
34
|
+
export { getDistance };
|
|
35
|
+
export { getMatrix };
|
|
36
|
+
export { on };
|
|
37
|
+
export { off };
|
|
38
|
+
}
|
|
39
|
+
declare function initialize(publishableKey: any): void;
|
|
40
|
+
declare function setLogLevel(level: any): void;
|
|
41
|
+
declare function setUserId(userId: any): void;
|
|
42
|
+
declare function setDescription(description: any): void;
|
|
43
|
+
declare function setMetadata(metadata: any): void;
|
|
44
|
+
declare function getPermissionsStatus(): Promise<any>;
|
|
45
|
+
declare function requestPermissions(background: any): void;
|
|
46
|
+
declare function getLocation(): Promise<any>;
|
|
47
|
+
declare function trackOnce(options: any): Promise<any>;
|
|
48
|
+
declare function trackVerified(): void;
|
|
49
|
+
declare function trackVerifiedToken(): void;
|
|
50
|
+
declare function startTrackingEfficient(): void;
|
|
51
|
+
declare function startTrackingResponsive(): void;
|
|
52
|
+
declare function startTrackingContinuous(): void;
|
|
53
|
+
declare function startTrackingCustom(options: any): void;
|
|
54
|
+
declare function mockTracking(options: any): void;
|
|
55
|
+
declare function stopTracking(): void;
|
|
56
|
+
declare function setForegroundServiceOptions(options: any): void;
|
|
57
|
+
declare function acceptEvent(eventId: any, verifiedPlaceId: any): void;
|
|
58
|
+
declare function rejectEvent(eventId: any): void;
|
|
59
|
+
declare function startTrip(options: any): Promise<any>;
|
|
60
|
+
declare function updateTrip(tripOptions: any): Promise<any>;
|
|
61
|
+
declare function completeTrip(): Promise<any>;
|
|
62
|
+
declare function cancelTrip(): Promise<any>;
|
|
63
|
+
declare function getContext(options: any): Promise<any>;
|
|
64
|
+
declare function searchPlaces(options: any): Promise<any>;
|
|
65
|
+
declare function searchGeofences(options: any): Promise<any>;
|
|
66
|
+
declare function autocomplete(options: any): Promise<any>;
|
|
67
|
+
declare function geocode(options: any): Promise<any>;
|
|
68
|
+
declare function reverseGeocode(options: any): Promise<any>;
|
|
69
|
+
declare function ipGeocode(): Promise<any>;
|
|
70
|
+
declare function getDistance(options: any): Promise<any>;
|
|
71
|
+
declare function getMatrix(options: any): Promise<any>;
|
|
72
|
+
declare function on(event: any, callback: any): void;
|
|
73
|
+
declare function off(event: any, callback: any): void;
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const radar_sdk_js_1 = __importDefault(require("radar-sdk-js"));
|
|
7
|
+
const initialize = (publishableKey) => {
|
|
8
|
+
radar_sdk_js_1.default.initialize(publishableKey);
|
|
9
|
+
};
|
|
10
|
+
const setLogLevel = (level) => {
|
|
11
|
+
// not implemented
|
|
12
|
+
};
|
|
13
|
+
const setUserId = (userId) => {
|
|
14
|
+
radar_sdk_js_1.default.setUserId(userId);
|
|
15
|
+
};
|
|
16
|
+
const setDeviceId = (deviceId, installId) => {
|
|
17
|
+
radar_sdk_js_1.default.setDeviceId(deviceId, installId);
|
|
18
|
+
};
|
|
19
|
+
const setDeviceType = (deviceType) => {
|
|
20
|
+
radar_sdk_js_1.default.setDeviceType(deviceType);
|
|
21
|
+
};
|
|
22
|
+
const setRequestHeaders = (headers) => {
|
|
23
|
+
radar_sdk_js_1.default.setRequestHeaders(headers);
|
|
24
|
+
};
|
|
25
|
+
const setDescription = (description) => {
|
|
26
|
+
radar_sdk_js_1.default.setDescription(description);
|
|
27
|
+
};
|
|
28
|
+
const setMetadata = (metadata) => {
|
|
29
|
+
radar_sdk_js_1.default.setMetadata(metadata);
|
|
30
|
+
};
|
|
31
|
+
const getPermissionsStatus = () => {
|
|
32
|
+
return new Promise(resolve => {
|
|
33
|
+
const navigator = window.navigator;
|
|
34
|
+
if (!navigator.permissions) {
|
|
35
|
+
resolve({
|
|
36
|
+
status: 'UNKNOWN'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
navigator.permissions.query({ name: 'geolocation' }).then((result) => {
|
|
41
|
+
resolve({
|
|
42
|
+
status: result.state === 'granted' ? 'GRANTED_FOREGROUND' : 'DENIED',
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
const requestPermissions = background => {
|
|
49
|
+
// not implemented
|
|
50
|
+
};
|
|
51
|
+
const getLocation = () => {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
radar_sdk_js_1.default.getLocation((err, result) => {
|
|
54
|
+
if (err)
|
|
55
|
+
reject(err);
|
|
56
|
+
else
|
|
57
|
+
resolve(result);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const trackOnce = options => {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
const callback = (err, { status, location, user, events }) => {
|
|
64
|
+
if (err) {
|
|
65
|
+
reject(err);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
resolve({
|
|
69
|
+
status,
|
|
70
|
+
location,
|
|
71
|
+
user,
|
|
72
|
+
events,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
if (options) {
|
|
77
|
+
radar_sdk_js_1.default.trackOnce(options.location ? options.location : options, callback);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
radar_sdk_js_1.default.trackOnce(callback);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const trackVerified = () => {
|
|
85
|
+
// not implemented
|
|
86
|
+
};
|
|
87
|
+
const trackVerifiedToken = () => {
|
|
88
|
+
// not implemented
|
|
89
|
+
};
|
|
90
|
+
const startTrackingEfficient = () => {
|
|
91
|
+
// not implemented
|
|
92
|
+
};
|
|
93
|
+
const startTrackingResponsive = () => {
|
|
94
|
+
// not implemented
|
|
95
|
+
};
|
|
96
|
+
const startTrackingContinuous = () => {
|
|
97
|
+
// not implemented
|
|
98
|
+
};
|
|
99
|
+
const startTrackingCustom = options => {
|
|
100
|
+
// not implemented
|
|
101
|
+
};
|
|
102
|
+
const mockTracking = options => {
|
|
103
|
+
// not implemented
|
|
104
|
+
};
|
|
105
|
+
const stopTracking = () => {
|
|
106
|
+
// not implemented
|
|
107
|
+
};
|
|
108
|
+
const setForegroundServiceOptions = options => {
|
|
109
|
+
// not implemented
|
|
110
|
+
};
|
|
111
|
+
const startTrip = options => {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
const callback = (err, { trip, events, status }) => {
|
|
114
|
+
if (err) {
|
|
115
|
+
reject(err);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
resolve({
|
|
119
|
+
trip,
|
|
120
|
+
events,
|
|
121
|
+
status
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
radar_sdk_js_1.default.startTrip(options, callback);
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const completeTrip = () => {
|
|
129
|
+
return new Promise((resolve, reject) => {
|
|
130
|
+
const callback = (err, { trip, events, status }) => {
|
|
131
|
+
if (err) {
|
|
132
|
+
reject(err);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
resolve({
|
|
136
|
+
trip,
|
|
137
|
+
events,
|
|
138
|
+
status
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
radar_sdk_js_1.default.completeTrip(callback);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const cancelTrip = () => {
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
const callback = (err, { trip, events, status }) => {
|
|
148
|
+
if (err) {
|
|
149
|
+
reject(err);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
resolve({
|
|
153
|
+
trip,
|
|
154
|
+
events,
|
|
155
|
+
status
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
radar_sdk_js_1.default.cancelTrip(callback);
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
const updateTrip = (tripOptions) => {
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
const callback = (err, { trip, events, status }) => {
|
|
165
|
+
if (err) {
|
|
166
|
+
reject(err);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
resolve({
|
|
170
|
+
trip,
|
|
171
|
+
events,
|
|
172
|
+
status
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
radar_sdk_js_1.default.updateTrip(tripOptions.options, tripOptions.status, callback);
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
const acceptEvent = (eventId, verifiedPlaceId) => {
|
|
180
|
+
// not implemented
|
|
181
|
+
};
|
|
182
|
+
const rejectEvent = eventId => {
|
|
183
|
+
// not implemented
|
|
184
|
+
};
|
|
185
|
+
const getContext = options => {
|
|
186
|
+
return new Promise((resolve, reject) => {
|
|
187
|
+
const callback = (err, { status, location, context }) => {
|
|
188
|
+
if (err) {
|
|
189
|
+
reject(err);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
resolve({
|
|
193
|
+
status,
|
|
194
|
+
location,
|
|
195
|
+
context,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
if (options) {
|
|
200
|
+
radar_sdk_js_1.default.getContext(options, callback);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
radar_sdk_js_1.default.getContext(callback);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
const searchPlaces = options => {
|
|
208
|
+
return new Promise((resolve, reject) => {
|
|
209
|
+
radar_sdk_js_1.default.searchPlaces(options, (err, { status, location, places }) => {
|
|
210
|
+
if (err) {
|
|
211
|
+
reject(err);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
resolve({
|
|
215
|
+
status,
|
|
216
|
+
location,
|
|
217
|
+
places,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
const searchGeofences = options => {
|
|
224
|
+
return new Promise((resolve, reject) => {
|
|
225
|
+
radar_sdk_js_1.default.searchGeofences(options, (err, { status, location, geofences }) => {
|
|
226
|
+
if (err) {
|
|
227
|
+
reject(err);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
resolve({
|
|
231
|
+
status,
|
|
232
|
+
location,
|
|
233
|
+
geofences,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
const autocomplete = options => {
|
|
240
|
+
return new Promise((resolve, reject) => {
|
|
241
|
+
radar_sdk_js_1.default.autocomplete(options, (err, { status, addresses }) => {
|
|
242
|
+
if (err) {
|
|
243
|
+
reject(err);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
resolve({
|
|
247
|
+
status,
|
|
248
|
+
addresses,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
const geocode = options => {
|
|
255
|
+
return new Promise((resolve, reject) => {
|
|
256
|
+
let newOptions = options;
|
|
257
|
+
if (typeof options === 'string')
|
|
258
|
+
newOptions = {
|
|
259
|
+
query: options
|
|
260
|
+
};
|
|
261
|
+
radar_sdk_js_1.default.geocode(newOptions, (err, { status, addresses }) => {
|
|
262
|
+
if (err) {
|
|
263
|
+
reject(err);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
resolve({
|
|
267
|
+
status,
|
|
268
|
+
addresses,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
const reverseGeocode = options => {
|
|
275
|
+
return new Promise((resolve, reject) => {
|
|
276
|
+
const callback = (err, { status, addresses }) => {
|
|
277
|
+
if (err) {
|
|
278
|
+
reject(err);
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
resolve({
|
|
282
|
+
status,
|
|
283
|
+
addresses,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
if (options) {
|
|
288
|
+
radar_sdk_js_1.default.reverseGeocode(options, callback);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
radar_sdk_js_1.default.reverseGeocode(callback);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
const ipGeocode = () => {
|
|
296
|
+
return new Promise((resolve, reject) => {
|
|
297
|
+
radar_sdk_js_1.default.ipGeocode((err, { status, address }) => {
|
|
298
|
+
if (err) {
|
|
299
|
+
reject(err);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
resolve({
|
|
303
|
+
status,
|
|
304
|
+
address,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
const getDistance = options => {
|
|
311
|
+
return new Promise((resolve, reject) => {
|
|
312
|
+
radar_sdk_js_1.default.getDistance(options, (err, { status, routes }) => {
|
|
313
|
+
if (err) {
|
|
314
|
+
reject(err);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
resolve({
|
|
318
|
+
status,
|
|
319
|
+
routes,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
const getMatrix = options => {
|
|
326
|
+
return new Promise((resolve, reject) => {
|
|
327
|
+
radar_sdk_js_1.default.getMatrix(options, (err, { origins, destinations, matrix, status }) => {
|
|
328
|
+
if (err) {
|
|
329
|
+
reject(err);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
resolve({
|
|
333
|
+
origins,
|
|
334
|
+
destinations,
|
|
335
|
+
matrix,
|
|
336
|
+
status,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
const on = (event, callback) => {
|
|
343
|
+
// not implemented
|
|
344
|
+
};
|
|
345
|
+
const off = (event, callback) => {
|
|
346
|
+
// not implemented
|
|
347
|
+
};
|
|
348
|
+
const Radar = {
|
|
349
|
+
initialize,
|
|
350
|
+
setLogLevel,
|
|
351
|
+
setUserId,
|
|
352
|
+
setDescription,
|
|
353
|
+
setMetadata,
|
|
354
|
+
getPermissionsStatus,
|
|
355
|
+
requestPermissions,
|
|
356
|
+
getLocation,
|
|
357
|
+
trackOnce,
|
|
358
|
+
trackVerified,
|
|
359
|
+
trackVerifiedToken,
|
|
360
|
+
startTrackingEfficient,
|
|
361
|
+
startTrackingResponsive,
|
|
362
|
+
startTrackingContinuous,
|
|
363
|
+
startTrackingCustom,
|
|
364
|
+
mockTracking,
|
|
365
|
+
stopTracking,
|
|
366
|
+
setForegroundServiceOptions,
|
|
367
|
+
acceptEvent,
|
|
368
|
+
rejectEvent,
|
|
369
|
+
startTrip,
|
|
370
|
+
updateTrip,
|
|
371
|
+
completeTrip,
|
|
372
|
+
cancelTrip,
|
|
373
|
+
getContext,
|
|
374
|
+
searchPlaces,
|
|
375
|
+
searchGeofences,
|
|
376
|
+
autocomplete,
|
|
377
|
+
geocode,
|
|
378
|
+
reverseGeocode,
|
|
379
|
+
ipGeocode,
|
|
380
|
+
getDistance,
|
|
381
|
+
getMatrix,
|
|
382
|
+
on,
|
|
383
|
+
off,
|
|
384
|
+
};
|
|
385
|
+
exports.default = Radar;
|