@situm/react-native 3.0.8 → 3.1.0-beta.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/src/main/java/com/situm/plugin/PluginHelper.java +3 -2
- package/android/src/main/java/com/situm/plugin/SitumMapper.java +38 -59
- package/android/src/main/java/com/situm/plugin/SitumPlugin.java +1 -0
- package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +1 -1
- package/ios/SitumPlugin.m +8 -2
- package/lib/commonjs/sdk/index.js +509 -251
- package/lib/commonjs/sdk/index.js.map +1 -1
- package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
- package/lib/commonjs/sdk/types/constants.js +31 -4
- package/lib/commonjs/sdk/types/constants.js.map +1 -1
- package/lib/commonjs/sdk/utils.js +103 -0
- package/lib/commonjs/sdk/utils.js.map +1 -0
- package/lib/commonjs/utils/requestPermission.js +9 -16
- package/lib/commonjs/utils/requestPermission.js.map +1 -1
- package/lib/commonjs/wayfinding/components/MapView.js +78 -134
- package/lib/commonjs/wayfinding/components/MapView.js.map +1 -1
- package/lib/commonjs/wayfinding/hooks/index.js +118 -278
- package/lib/commonjs/wayfinding/hooks/index.js.map +1 -1
- package/lib/commonjs/wayfinding/store/index.js +17 -6
- package/lib/commonjs/wayfinding/store/index.js.map +1 -1
- package/lib/commonjs/wayfinding/types/index.js +1 -3
- package/lib/commonjs/wayfinding/types/index.js.map +1 -1
- package/lib/commonjs/wayfinding/utils/mapper.js +128 -71
- package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
- package/lib/module/sdk/index.js +509 -249
- package/lib/module/sdk/index.js.map +1 -1
- package/lib/module/sdk/nativeInterface.js.map +1 -1
- package/lib/module/sdk/types/constants.js +27 -3
- package/lib/module/sdk/types/constants.js.map +1 -1
- package/lib/module/sdk/utils.js +94 -0
- package/lib/module/sdk/utils.js.map +1 -0
- package/lib/module/utils/requestPermission.js +9 -16
- package/lib/module/utils/requestPermission.js.map +1 -1
- package/lib/module/wayfinding/components/MapView.js +77 -133
- package/lib/module/wayfinding/components/MapView.js.map +1 -1
- package/lib/module/wayfinding/hooks/index.js +119 -278
- package/lib/module/wayfinding/hooks/index.js.map +1 -1
- package/lib/module/wayfinding/store/index.js +15 -6
- package/lib/module/wayfinding/store/index.js.map +1 -1
- package/lib/module/wayfinding/types/index.js +1 -1
- package/lib/module/wayfinding/types/index.js.map +1 -1
- package/lib/module/wayfinding/utils/mapper.js +123 -72
- package/lib/module/wayfinding/utils/mapper.js.map +1 -1
- package/lib/typescript/src/sdk/index.d.ts +183 -145
- package/lib/typescript/src/sdk/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/nativeInterface.d.ts +59 -0
- package/lib/typescript/src/sdk/nativeInterface.d.ts.map +1 -1
- package/lib/typescript/src/sdk/types/constants.d.ts +24 -3
- package/lib/typescript/src/sdk/types/constants.d.ts.map +1 -1
- package/lib/typescript/src/sdk/types/index.d.ts +91 -146
- package/lib/typescript/src/sdk/types/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/utils.d.ts +53 -0
- package/lib/typescript/src/sdk/utils.d.ts.map +1 -0
- package/lib/typescript/src/utils/requestPermission.d.ts +1 -1
- package/lib/typescript/src/utils/requestPermission.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/components/MapView.d.ts +16 -28
- package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/hooks/index.d.ts +3 -34
- package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/store/index.d.ts +8 -6
- package/lib/typescript/src/wayfinding/store/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/types/index.d.ts +36 -17
- package/lib/typescript/src/wayfinding/types/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts +16 -11
- package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/sdk/index.ts +467 -476
- package/src/sdk/nativeInterface.ts +149 -1
- package/src/sdk/types/constants.ts +27 -3
- package/src/sdk/types/index.ts +98 -158
- package/src/sdk/utils.ts +129 -0
- package/src/utils/requestPermission.ts +18 -23
- package/src/wayfinding/components/MapView.tsx +145 -215
- package/src/wayfinding/hooks/index.ts +155 -385
- package/src/wayfinding/store/index.tsx +19 -9
- package/src/wayfinding/types/index.ts +49 -15
- package/src/wayfinding/utils/mapper.ts +145 -104
package/src/sdk/index.ts
CHANGED
|
@@ -1,56 +1,89 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
3
|
-
import invariant from "invariant";
|
|
4
|
-
import { NativeEventEmitter, NativeModules, Platform } from "react-native";
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
export * from "./types/constants";
|
|
4
|
+
import { NativeEventEmitter, NativeModules, Platform } from "react-native";
|
|
8
5
|
|
|
9
6
|
import packageJson from "../../package.json";
|
|
10
7
|
import { logError } from "../utils/logError";
|
|
8
|
+
import type { SitumPluginInterface } from "./nativeInterface";
|
|
11
9
|
import type {
|
|
12
10
|
Building,
|
|
13
|
-
|
|
11
|
+
BuildingInfo,
|
|
12
|
+
ConfigurationOptions,
|
|
13
|
+
Directions,
|
|
14
14
|
DirectionsOptions,
|
|
15
|
+
Error,
|
|
15
16
|
Floor,
|
|
16
|
-
|
|
17
|
+
Geofence,
|
|
18
|
+
Location,
|
|
19
|
+
LocationRequest,
|
|
20
|
+
LocationStatus,
|
|
21
|
+
NavigationProgress,
|
|
17
22
|
NavigationRequest,
|
|
23
|
+
Poi,
|
|
24
|
+
PoiCategory,
|
|
25
|
+
PoiIcon,
|
|
26
|
+
Point,
|
|
27
|
+
SdkVersion,
|
|
18
28
|
} from "./types";
|
|
29
|
+
import { SdkNavigationUpdateType } from "./types/constants";
|
|
30
|
+
import { exceptionWrapper, promiseWrapper } from "./utils";
|
|
31
|
+
|
|
32
|
+
export type * from "./types";
|
|
33
|
+
export * from "./types/constants";
|
|
19
34
|
|
|
20
35
|
const LINKING_ERROR =
|
|
21
|
-
`The package '
|
|
36
|
+
`The package 'react-native' doesn't seem to be linked. Make sure: \n\n` +
|
|
22
37
|
Platform.select({ ios: "- You have run 'pod install'\n", default: "" }) +
|
|
23
38
|
"- You rebuilt the app after installing the package\n" +
|
|
24
39
|
"- You are not using Expo managed workflow\n";
|
|
25
40
|
|
|
26
|
-
const RNCSitumPlugin =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
const RNCSitumPlugin =
|
|
42
|
+
(NativeModules.RNCSitumPlugin as SitumPluginInterface) ||
|
|
43
|
+
(new Proxy(
|
|
44
|
+
{},
|
|
45
|
+
{
|
|
46
|
+
get() {
|
|
47
|
+
throw new Error(LINKING_ERROR);
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
) as SitumPluginInterface);
|
|
36
51
|
|
|
37
52
|
const SitumPluginEventEmitter = new NativeEventEmitter(RNCSitumPlugin);
|
|
38
53
|
|
|
39
|
-
|
|
40
|
-
let
|
|
54
|
+
// TODO: these do not act as state, not reliable
|
|
55
|
+
let positioningRunning = false;
|
|
56
|
+
let navigationRunning = false;
|
|
41
57
|
let realtimeSubscriptions = [];
|
|
42
58
|
|
|
43
|
-
export default {
|
|
59
|
+
export default class SitumPlugin {
|
|
44
60
|
/**
|
|
45
|
-
*
|
|
61
|
+
* Whether the positioning is currently in execution.
|
|
62
|
+
* @returns boolean
|
|
63
|
+
*/
|
|
64
|
+
static positioningIsRunning: () => boolean = () => positioningRunning;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether the navigation is currently in execution.
|
|
68
|
+
* @returns boolean
|
|
69
|
+
*/
|
|
70
|
+
static navigationIsRunning: () => boolean = () => navigationRunning;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Initializes {@link SitumPlugin}.
|
|
46
74
|
*
|
|
47
|
-
*
|
|
75
|
+
* This method must be called before invoking any other methods.
|
|
48
76
|
* This method can be safely called many times as it will only initialise the SDK
|
|
49
77
|
* if it is not already initialised.
|
|
78
|
+
*
|
|
79
|
+
* @returns void
|
|
80
|
+
* @throw Exception
|
|
50
81
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
82
|
+
static init = () => {
|
|
83
|
+
return exceptionWrapper<void>(() => {
|
|
84
|
+
RNCSitumPlugin.initSitumSDK();
|
|
85
|
+
});
|
|
86
|
+
};
|
|
54
87
|
|
|
55
88
|
/**
|
|
56
89
|
* Provides your API key to the Situm SDK.
|
|
@@ -58,17 +91,18 @@ export default {
|
|
|
58
91
|
* This key is generated for your application in the Dashboard.
|
|
59
92
|
* Old credentials will be removed.
|
|
60
93
|
*
|
|
61
|
-
* @param email user's email.
|
|
62
94
|
* @param apiKey user's apikey.
|
|
63
|
-
*
|
|
95
|
+
*
|
|
96
|
+
* @returns void
|
|
97
|
+
* @throw Exception
|
|
64
98
|
*/
|
|
65
|
-
setApiKey:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
99
|
+
static setApiKey = (apiKey: string) => {
|
|
100
|
+
return exceptionWrapper<void>(({ onCallback }) => {
|
|
101
|
+
RNCSitumPlugin.setApiKey("email@email.com", apiKey, (response) => {
|
|
102
|
+
onCallback(response, "Failed to set API key.");
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
72
106
|
|
|
73
107
|
/**
|
|
74
108
|
* Provides user's email and password. This credentials will be used to obtain a
|
|
@@ -78,531 +112,365 @@ export default {
|
|
|
78
112
|
*
|
|
79
113
|
* @param email user's email.
|
|
80
114
|
* @param password user's password.
|
|
81
|
-
*
|
|
115
|
+
*
|
|
116
|
+
* @returns void
|
|
117
|
+
* @throw Exception
|
|
82
118
|
*/
|
|
83
|
-
setUserPass:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
119
|
+
static setUserPass = (email: string, password: string) => {
|
|
120
|
+
return exceptionWrapper<void>(({ onCallback }) => {
|
|
121
|
+
RNCSitumPlugin.setUserPass(email, password, (response) => {
|
|
122
|
+
onCallback(response, "Failed to set user credentials.");
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
90
126
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Sets the API's base URL to retrieve the data.
|
|
129
|
+
*
|
|
130
|
+
* @param url user's email.
|
|
131
|
+
*
|
|
132
|
+
* @returns void
|
|
133
|
+
* @throw Exception
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
static setDashboardURL = (url: string) => {
|
|
137
|
+
return exceptionWrapper<void>(({ onCallback }) => {
|
|
138
|
+
RNCSitumPlugin.setDashboardURL(url, (response: { success: boolean }) => {
|
|
139
|
+
onCallback(response, "Failed to set dashboard URL.");
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
94
143
|
|
|
95
144
|
/**
|
|
96
145
|
* Set to true if you want the SDK to download the configuration from the Situm API
|
|
97
|
-
* and use it by default. Right now it only affects the LocationRequest.
|
|
146
|
+
* and use it by default. Right now it only affects the {@link LocationRequest}.
|
|
98
147
|
* Default value is true from SDK version 2.83.5
|
|
99
148
|
*
|
|
100
|
-
* @param useRemoteConfig
|
|
101
|
-
*
|
|
149
|
+
* @param useRemoteConfig
|
|
150
|
+
*
|
|
151
|
+
* @returns void
|
|
152
|
+
* @throw Exception
|
|
153
|
+
*/
|
|
154
|
+
static setUseRemoteConfig = (useRemoteConfig: boolean) => {
|
|
155
|
+
return exceptionWrapper<void>(({ onCallback }) => {
|
|
156
|
+
RNCSitumPlugin.setUseRemoteConfig(
|
|
157
|
+
useRemoteConfig ? "true" : "false",
|
|
158
|
+
(response) => {
|
|
159
|
+
onCallback(response, "Failed to set remote config");
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Sets the max seconds the cache is valid
|
|
167
|
+
*
|
|
168
|
+
* @returns void
|
|
169
|
+
* @throw Exception
|
|
102
170
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
171
|
+
private static setMaxCacheAge = (cacheAge: number) => {
|
|
172
|
+
return exceptionWrapper<void>(({ onCallback }) => {
|
|
173
|
+
RNCSitumPlugin.setCacheMaxAge(cacheAge, (response) => {
|
|
174
|
+
onCallback(response, "Failed to set cache max age");
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
};
|
|
106
178
|
|
|
107
179
|
/**
|
|
108
|
-
* Sets the
|
|
109
|
-
*
|
|
180
|
+
* Sets the SDK {@link ConfigurationOptions}.
|
|
181
|
+
*
|
|
182
|
+
* @param options {@link ConfigurationOptions}
|
|
110
183
|
*
|
|
111
|
-
* @
|
|
112
|
-
* @
|
|
184
|
+
* @returns void
|
|
185
|
+
* @throw Exception
|
|
113
186
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
187
|
+
static setConfiguration = (options: ConfigurationOptions) => {
|
|
188
|
+
return exceptionWrapper<void>(() => {
|
|
189
|
+
if (options.useRemoteConfig !== undefined) {
|
|
190
|
+
SitumPlugin.setUseRemoteConfig(options.useRemoteConfig);
|
|
191
|
+
}
|
|
192
|
+
if (options.cacheMaxAge !== undefined) {
|
|
193
|
+
SitumPlugin.setMaxCacheAge(options.cacheMaxAge);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Handle rest of configuration options
|
|
197
|
+
});
|
|
198
|
+
};
|
|
117
199
|
|
|
118
200
|
/**
|
|
119
201
|
* Invalidate all the resources in the cache
|
|
202
|
+
*
|
|
203
|
+
* @returns void
|
|
204
|
+
* @throw Exception
|
|
120
205
|
*/
|
|
121
|
-
invalidateCache
|
|
122
|
-
|
|
123
|
-
|
|
206
|
+
static invalidateCache = () => {
|
|
207
|
+
return exceptionWrapper<void>(() => {
|
|
208
|
+
RNCSitumPlugin.invalidateCache();
|
|
209
|
+
});
|
|
210
|
+
};
|
|
124
211
|
|
|
125
212
|
/**
|
|
126
213
|
* Gets the list of versions for the current plugin and environment
|
|
127
214
|
*
|
|
128
|
-
* @
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
android?: string
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
callback(versions);
|
|
148
|
-
},
|
|
215
|
+
* @returns void
|
|
216
|
+
* @throw Exception
|
|
217
|
+
*/
|
|
218
|
+
static sdkVersion = () => {
|
|
219
|
+
return exceptionWrapper<SdkVersion>(({ onSuccess }) => {
|
|
220
|
+
const versions: { react_native: string; ios?: string; android?: string } =
|
|
221
|
+
{
|
|
222
|
+
react_native: packageJson.version,
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
if (Platform.OS === "ios") {
|
|
226
|
+
versions.ios = packageJson.sdkVersions.ios;
|
|
227
|
+
} else {
|
|
228
|
+
versions.android = packageJson.sdkVersions.android;
|
|
229
|
+
}
|
|
230
|
+
onSuccess(versions);
|
|
231
|
+
});
|
|
232
|
+
};
|
|
149
233
|
|
|
150
234
|
/**
|
|
151
235
|
* Returns the device identifier that has generated the location
|
|
152
236
|
*
|
|
153
|
-
* @
|
|
237
|
+
* @returns void
|
|
238
|
+
* @throw Exception
|
|
154
239
|
*/
|
|
155
|
-
getDeviceId
|
|
156
|
-
|
|
157
|
-
|
|
240
|
+
static getDeviceId = () => {
|
|
241
|
+
return exceptionWrapper<string>(({ onSuccess }) => {
|
|
242
|
+
RNCSitumPlugin.getDeviceId(onSuccess);
|
|
243
|
+
});
|
|
244
|
+
};
|
|
158
245
|
|
|
159
246
|
/**
|
|
160
|
-
*
|
|
161
|
-
* and stores it internally for subsequent requests
|
|
247
|
+
* Downloads all the {@link Building}s for the current user.
|
|
162
248
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
249
|
+
static fetchBuildings = () => {
|
|
250
|
+
return promiseWrapper<Building[]>(({ onSuccess, onError }) => {
|
|
251
|
+
RNCSitumPlugin.fetchBuildings(onSuccess, onError);
|
|
252
|
+
});
|
|
253
|
+
};
|
|
166
254
|
|
|
167
255
|
/**
|
|
168
|
-
*
|
|
256
|
+
* Downloads all the building data for the selected building. This info includes
|
|
257
|
+
* {@link Floor}, indoor and outdoor {@link Poi}s, events and paths. Also it download floor
|
|
258
|
+
* maps and {@link PoiCategory} icons to local storage.
|
|
169
259
|
*
|
|
170
|
-
* @param
|
|
171
|
-
* @param error function called on failure, returns an error string
|
|
260
|
+
* @param building {@link Building}
|
|
172
261
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
RNCSitumPlugin.fetchBuildings(success, error || logError);
|
|
180
|
-
},
|
|
262
|
+
static fetchBuildingInfo = (building: Building) => {
|
|
263
|
+
return promiseWrapper<BuildingInfo>(({ onSuccess, onError }) => {
|
|
264
|
+
RNCSitumPlugin.fetchBuildingInfo(building, onSuccess, onError);
|
|
265
|
+
});
|
|
266
|
+
};
|
|
181
267
|
|
|
182
268
|
/**
|
|
183
|
-
*
|
|
184
|
-
* floors, indoor and outdoor POIs, events and paths. Also it download floor
|
|
185
|
-
* maps and POI category icons to local storage.
|
|
269
|
+
* (Experimental) Downloads the tiled-map of a certain building
|
|
186
270
|
*
|
|
187
|
-
* @param building
|
|
188
|
-
* @param success function called on sucess, returns a list of Building objects
|
|
189
|
-
* @param error function called on failure, returns an error string
|
|
271
|
+
* @param building {@link Building} whose tiles will be downloaded
|
|
190
272
|
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
invariant(
|
|
197
|
-
typeof success === "function",
|
|
198
|
-
"Must provide a valid success callback."
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
RNCSitumPlugin.fetchBuildingInfo(building, success, error || logError);
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
fetchTilesFromBuilding: function (
|
|
205
|
-
building: Building,
|
|
206
|
-
success: Function,
|
|
207
|
-
error?: Function
|
|
208
|
-
) {
|
|
209
|
-
invariant(
|
|
210
|
-
typeof success === "function",
|
|
211
|
-
"Must provide a valid success callback."
|
|
212
|
-
);
|
|
213
|
-
RNCSitumPlugin.fetchTilesFromBuilding(building, success, error || logError);
|
|
214
|
-
},
|
|
273
|
+
static fetchTilesFromBuilding = (building: Building) => {
|
|
274
|
+
return promiseWrapper<any>(({ onSuccess, onError }) => {
|
|
275
|
+
RNCSitumPlugin.fetchTilesFromBuilding(building, onSuccess, onError);
|
|
276
|
+
});
|
|
277
|
+
};
|
|
215
278
|
|
|
216
279
|
/**
|
|
217
|
-
*
|
|
280
|
+
* Downloads all the floors of a building
|
|
218
281
|
*
|
|
219
|
-
* @param building
|
|
220
|
-
* @param success function called on sucess, returns a list of Floor objects
|
|
221
|
-
* @param error function called on failure, returns an error string
|
|
282
|
+
* @param building {@link Building}
|
|
222
283
|
*/
|
|
223
|
-
fetchFloorsFromBuilding:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
invariant(
|
|
229
|
-
typeof success === "function",
|
|
230
|
-
"Must provide a valid success callback."
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
RNCSitumPlugin.fetchFloorsFromBuilding(
|
|
234
|
-
building,
|
|
235
|
-
success,
|
|
236
|
-
error || logError
|
|
237
|
-
);
|
|
238
|
-
},
|
|
284
|
+
static fetchFloorsFromBuilding = (building: Building) => {
|
|
285
|
+
return promiseWrapper<Floor[]>(({ onSuccess, onError }) => {
|
|
286
|
+
RNCSitumPlugin.fetchFloorsFromBuilding(building, onSuccess, onError);
|
|
287
|
+
});
|
|
288
|
+
};
|
|
239
289
|
|
|
240
290
|
/**
|
|
241
|
-
*
|
|
291
|
+
* Downloads the map image of a {@link Floor}
|
|
242
292
|
*
|
|
243
|
-
* @param floor
|
|
244
|
-
* @param success function called on sucess, returns a list of Map url objects
|
|
245
|
-
* @param error function called on failure, returns an error string
|
|
293
|
+
* @param floor {@link Floor}
|
|
246
294
|
*/
|
|
247
|
-
fetchMapFromFloor:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
invariant(
|
|
253
|
-
typeof success === "function",
|
|
254
|
-
"Must provide a valid success callback."
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
RNCSitumPlugin.fetchMapFromFloor(floor, success, error || logError);
|
|
258
|
-
},
|
|
295
|
+
static fetchMapFromFloor = (floor: Floor) => {
|
|
296
|
+
return promiseWrapper<string>(({ onSuccess, onError }) => {
|
|
297
|
+
RNCSitumPlugin.fetchMapFromFloor(floor, onSuccess, onError);
|
|
298
|
+
});
|
|
299
|
+
};
|
|
259
300
|
|
|
260
301
|
/**
|
|
261
|
-
* Get the geofences of a
|
|
302
|
+
* Get the geofences of a {@link Building}
|
|
262
303
|
*
|
|
263
|
-
* @param building
|
|
264
|
-
* @param success function called on sucess, returns a list of Building objects
|
|
265
|
-
* @param error function called on failure, returns an error string
|
|
304
|
+
* @param building {@link Building}
|
|
266
305
|
*/
|
|
267
|
-
fetchGeofencesFromBuilding:
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
invariant(
|
|
273
|
-
typeof success === "function",
|
|
274
|
-
"Must provide a valid success callback."
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
RNCSitumPlugin.fetchGeofencesFromBuilding(
|
|
278
|
-
building,
|
|
279
|
-
success,
|
|
280
|
-
error || logError
|
|
281
|
-
);
|
|
282
|
-
},
|
|
306
|
+
static fetchGeofencesFromBuilding = (building: Building) => {
|
|
307
|
+
return promiseWrapper<Geofence[]>(({ onSuccess, onError }) => {
|
|
308
|
+
RNCSitumPlugin.fetchGeofencesFromBuilding(building, onSuccess, onError);
|
|
309
|
+
});
|
|
310
|
+
};
|
|
283
311
|
|
|
284
312
|
/**
|
|
285
|
-
* Get all
|
|
286
|
-
*
|
|
287
|
-
* @param success function called on sucess, returns a list of POI categories
|
|
288
|
-
* @param error function called on failure, returns an error string
|
|
313
|
+
* Get all {@link PoiCategory}, download and cache their icons asynchronously.
|
|
289
314
|
*/
|
|
290
|
-
fetchPoiCategories
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
RNCSitumPlugin.fetchPoiCategories(success, error || logError);
|
|
297
|
-
},
|
|
315
|
+
static fetchPoiCategories = () => {
|
|
316
|
+
return promiseWrapper<PoiCategory[]>(({ onSuccess, onError }) => {
|
|
317
|
+
RNCSitumPlugin.fetchPoiCategories(onSuccess, onError);
|
|
318
|
+
});
|
|
319
|
+
};
|
|
298
320
|
|
|
299
321
|
/**
|
|
300
|
-
* Get the normal
|
|
322
|
+
* Get the normal {@link PoiIcon} for a category
|
|
301
323
|
*
|
|
302
|
-
* @param category
|
|
303
|
-
* @param success function called on sucess, returns the icon in normal state.
|
|
304
|
-
* @param error function called on failure, returns an error string
|
|
324
|
+
* @param category {@link PoiCategory}. Not null.
|
|
305
325
|
*/
|
|
306
|
-
fetchPoiCategoryIconNormal:
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
invariant(
|
|
312
|
-
typeof success === "function",
|
|
313
|
-
"Must provide a valid success callback."
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
RNCSitumPlugin.fetchPoiCategoryIconNormal(
|
|
317
|
-
category,
|
|
318
|
-
success,
|
|
319
|
-
error || logError
|
|
320
|
-
);
|
|
321
|
-
},
|
|
326
|
+
static fetchPoiCategoryIconNormal = (category: PoiCategory) => {
|
|
327
|
+
return promiseWrapper<PoiIcon>(({ onSuccess, onError }) => {
|
|
328
|
+
RNCSitumPlugin.fetchPoiCategoryIconNormal(category, onSuccess, onError);
|
|
329
|
+
});
|
|
330
|
+
};
|
|
322
331
|
|
|
323
332
|
/**
|
|
324
|
-
* Get the selected
|
|
333
|
+
* Get the selected {@link PoiIcon} for a {@link PoiCategory}
|
|
325
334
|
*
|
|
326
|
-
* @param category
|
|
327
|
-
* @param success function called on sucess, returns the icon in selected state.
|
|
328
|
-
* @param error function called on failure, returns an error string
|
|
335
|
+
* @param category {@link PoiCategory}. Not null.
|
|
329
336
|
*/
|
|
330
|
-
fetchPoiCategoryIconSelected:
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
invariant(
|
|
336
|
-
typeof success === "function",
|
|
337
|
-
"Must provide a valid success callback."
|
|
338
|
-
);
|
|
339
|
-
|
|
340
|
-
RNCSitumPlugin.fetchPoiCategoryIconSelected(
|
|
341
|
-
category,
|
|
342
|
-
success,
|
|
343
|
-
error || logError
|
|
344
|
-
);
|
|
345
|
-
},
|
|
337
|
+
static fetchPoiCategoryIconSelected = (category: PoiCategory) => {
|
|
338
|
+
return promiseWrapper<PoiIcon>(({ onSuccess, onError }) => {
|
|
339
|
+
RNCSitumPlugin.fetchPoiCategoryIconSelected(category, onSuccess, onError);
|
|
340
|
+
});
|
|
341
|
+
};
|
|
346
342
|
|
|
347
343
|
/**
|
|
348
|
-
* Download the indoor
|
|
344
|
+
* Download the indoor {@link Poi}s of a {@link Building}
|
|
349
345
|
*
|
|
350
|
-
* @param building
|
|
351
|
-
* @param success function called on sucess, returns a list of POI objects
|
|
352
|
-
* @param error function called on failure, returns an error string
|
|
346
|
+
* @param building {@link Building}
|
|
353
347
|
*/
|
|
354
|
-
fetchIndoorPOIsFromBuilding:
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
invariant(
|
|
360
|
-
typeof success === "function",
|
|
361
|
-
"Must provide a valid success callback."
|
|
362
|
-
);
|
|
363
|
-
|
|
364
|
-
RNCSitumPlugin.fetchIndoorPOIsFromBuilding(
|
|
365
|
-
building,
|
|
366
|
-
success,
|
|
367
|
-
error || logError
|
|
368
|
-
);
|
|
369
|
-
},
|
|
348
|
+
static fetchIndoorPOIsFromBuilding = (building: Building) => {
|
|
349
|
+
return promiseWrapper<Poi[]>(({ onSuccess, onError }) => {
|
|
350
|
+
RNCSitumPlugin.fetchIndoorPOIsFromBuilding(building, onSuccess, onError);
|
|
351
|
+
});
|
|
352
|
+
};
|
|
370
353
|
|
|
371
354
|
/**
|
|
372
|
-
* Download the outdoor
|
|
355
|
+
* Download the outdoor {@link Poi}s of a {@link Building}
|
|
373
356
|
*
|
|
374
|
-
* @param building
|
|
375
|
-
* @param success function called on sucess, returns a list of POI objects
|
|
376
|
-
* @param error function called on failure, returns an error string
|
|
357
|
+
* @param building {@link Building}
|
|
377
358
|
*/
|
|
378
|
-
fetchOutdoorPOIsFromBuilding:
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
invariant(
|
|
384
|
-
typeof success === "function",
|
|
385
|
-
"Must provide a valid success callback."
|
|
386
|
-
);
|
|
387
|
-
|
|
388
|
-
RNCSitumPlugin.fetchOutdoorPOIsFromBuilding(
|
|
389
|
-
building,
|
|
390
|
-
success,
|
|
391
|
-
error || logError
|
|
392
|
-
);
|
|
393
|
-
},
|
|
359
|
+
static fetchOutdoorPOIsFromBuilding = (building: Building) => {
|
|
360
|
+
return promiseWrapper<Poi[]>(({ onSuccess, onError }) => {
|
|
361
|
+
RNCSitumPlugin.fetchOutdoorPOIsFromBuilding(building, onSuccess, onError);
|
|
362
|
+
});
|
|
363
|
+
};
|
|
394
364
|
|
|
395
365
|
/**
|
|
396
|
-
*
|
|
366
|
+
* Starts positioning.
|
|
397
367
|
*
|
|
398
|
-
* @param
|
|
399
|
-
* @param success Callback to asynchronously receive the events of a building. Not null.
|
|
400
|
-
* @param error function called on failure, returns an error string
|
|
368
|
+
* @param {LocationRequest} locationRequest Positioning options to configure how positioning will behave
|
|
401
369
|
*/
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
error?: Function
|
|
406
|
-
): void {
|
|
407
|
-
invariant(
|
|
408
|
-
typeof success === "function",
|
|
409
|
-
"Must provide a valid success callback."
|
|
410
|
-
);
|
|
370
|
+
static requestLocationUpdates = (locationRequest?: LocationRequest) => {
|
|
371
|
+
return exceptionWrapper<void>(() => {
|
|
372
|
+
if (SitumPlugin.positioningIsRunning()) return;
|
|
411
373
|
|
|
412
|
-
|
|
413
|
-
building,
|
|
414
|
-
success,
|
|
415
|
-
error || logError
|
|
416
|
-
);
|
|
417
|
-
},
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Starts positioning with the configuration specified by the LocationRequest;
|
|
421
|
-
* computed geolocations, status codes and errors will be received through the LocationListener callbacks.
|
|
422
|
-
* You may call this method more than once, with the following effect:
|
|
423
|
-
*
|
|
424
|
-
* - If you provide a new LocationRequest instance, positioning will be re-started
|
|
425
|
-
* with the new positioning options specified by this new instance.
|
|
426
|
-
* - If you provide a new LocationListener, the former LocationListener will be
|
|
427
|
-
* replaced, therefore geolocations will be communicated to the new one.
|
|
428
|
-
* - If neither LocationRequest nor LocationListener change, nothing will happen.
|
|
429
|
-
* You may stop positioning at any time by calling the LocationManager.removeUpdates() method.
|
|
430
|
-
*
|
|
431
|
-
* @param location callback to use when location is udpated
|
|
432
|
-
* @param status callback to use when the positioning status changes
|
|
433
|
-
* @param error callback to use when error is raised
|
|
434
|
-
* @param locationOptions hashmap with options
|
|
435
|
-
*
|
|
436
|
-
* @returns the id of the subscription
|
|
437
|
-
*/
|
|
438
|
-
startPositioning: function (
|
|
439
|
-
location: (event: any) => void,
|
|
440
|
-
status: Function,
|
|
441
|
-
error?: Function,
|
|
442
|
-
options?: LocationRequestOptions
|
|
443
|
-
): void {
|
|
444
|
-
this.requestAuthorization();
|
|
445
|
-
return this.startPositioningUpdates(
|
|
446
|
-
location,
|
|
447
|
-
status,
|
|
448
|
-
error || logError,
|
|
449
|
-
options || {}
|
|
450
|
-
);
|
|
451
|
-
},
|
|
374
|
+
RNCSitumPlugin.startPositioning(locationRequest || {});
|
|
452
375
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
positioningSubscriptions.push(
|
|
464
|
-
SitumPluginEventEmitter.addListener("locationChanged", location),
|
|
465
|
-
SitumPluginEventEmitter.addListener("statusChanged", status),
|
|
466
|
-
error
|
|
467
|
-
? SitumPluginEventEmitter.addListener(
|
|
468
|
-
"locationError",
|
|
469
|
-
error || logError
|
|
470
|
-
)
|
|
471
|
-
: null
|
|
472
|
-
);
|
|
473
|
-
// Call native:
|
|
474
|
-
RNCSitumPlugin.startPositioning(options || {});
|
|
475
|
-
},
|
|
376
|
+
positioningRunning = true;
|
|
377
|
+
|
|
378
|
+
SitumPlugin.onLocationUpdate((loc: Location) => {
|
|
379
|
+
if (!SitumPlugin.navigationIsRunning()) return;
|
|
380
|
+
|
|
381
|
+
SitumPlugin.updateNavigationWithLocation(loc);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
};
|
|
476
385
|
|
|
477
386
|
/**
|
|
478
387
|
* Stops positioning, removing all location updates
|
|
479
|
-
*
|
|
480
|
-
* @param callback the callback to use when the function successfully ends
|
|
481
|
-
* @returns
|
|
482
388
|
*/
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
389
|
+
static removeLocationUpdates = () => {
|
|
390
|
+
return exceptionWrapper<void>(() => {
|
|
391
|
+
if (!SitumPlugin.positioningIsRunning()) return;
|
|
392
|
+
|
|
393
|
+
RNCSitumPlugin.stopPositioning((response) => {
|
|
394
|
+
if (response.success) {
|
|
395
|
+
positioningRunning = false;
|
|
396
|
+
} else {
|
|
397
|
+
throw "Situm > hook > Could not stop positioning";
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
};
|
|
486
402
|
|
|
487
403
|
/**
|
|
488
404
|
* Calculates a route between two points. The result is provided
|
|
489
405
|
* asynchronously using the callback.
|
|
490
406
|
*
|
|
491
|
-
* @param
|
|
492
|
-
* @param
|
|
493
|
-
* @param
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
"Must provide a valid success callback."
|
|
508
|
-
);
|
|
509
|
-
|
|
510
|
-
RNCSitumPlugin.requestDirections(
|
|
511
|
-
directionParams,
|
|
512
|
-
success,
|
|
513
|
-
error || logError
|
|
514
|
-
);
|
|
515
|
-
},
|
|
407
|
+
* @param building {@link Building}
|
|
408
|
+
* @param from {@link Point} route origin
|
|
409
|
+
* @param to {@link Point} route destination
|
|
410
|
+
* @param directionOptions {@link DirectionsOptions}
|
|
411
|
+
*/
|
|
412
|
+
static requestDirections = (
|
|
413
|
+
building: Building,
|
|
414
|
+
from: Point | Location,
|
|
415
|
+
to: Point | Poi,
|
|
416
|
+
directionOptions?: DirectionsOptions
|
|
417
|
+
) => {
|
|
418
|
+
return promiseWrapper<Directions>(({ onSuccess, onError }) => {
|
|
419
|
+
const params = [building, from, to, directionOptions || {}];
|
|
420
|
+
RNCSitumPlugin.requestDirections(params, onSuccess, onError);
|
|
421
|
+
});
|
|
422
|
+
};
|
|
516
423
|
|
|
517
424
|
/**
|
|
518
425
|
* Set the navigation params, and the listener that receives the updated
|
|
519
426
|
* navigation progress.
|
|
520
427
|
*
|
|
521
428
|
* Can only exist one navigation with one listener at a time. If this method was
|
|
522
|
-
* previously invoked, but
|
|
429
|
+
* previously invoked, but removeLocationUpdates() wasn't, removeLocationUpdates()
|
|
430
|
+
* is called internally.
|
|
523
431
|
*
|
|
524
|
-
* @param
|
|
525
|
-
* @param error function called on failure, returns an error string
|
|
526
|
-
* @param options
|
|
432
|
+
* @param options {@link NavigationRequest}
|
|
527
433
|
*/
|
|
528
|
-
requestNavigationUpdates
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
navigationSubscriptions.push(
|
|
535
|
-
SitumPluginEventEmitter.addListener(
|
|
536
|
-
"navigationUpdated",
|
|
537
|
-
navigationUpdates
|
|
538
|
-
)
|
|
539
|
-
);
|
|
540
|
-
navigationSubscriptions.push(
|
|
541
|
-
error
|
|
542
|
-
? SitumPluginEventEmitter.addListener(
|
|
543
|
-
"navigationError",
|
|
544
|
-
error || logError
|
|
545
|
-
)
|
|
546
|
-
: null
|
|
547
|
-
);
|
|
548
|
-
},
|
|
434
|
+
static requestNavigationUpdates = (options?: NavigationRequest) => {
|
|
435
|
+
return exceptionWrapper<void>(() => {
|
|
436
|
+
RNCSitumPlugin.requestNavigationUpdates(options || {});
|
|
437
|
+
navigationRunning = true;
|
|
438
|
+
});
|
|
439
|
+
};
|
|
549
440
|
|
|
550
441
|
/**
|
|
551
442
|
* Informs NavigationManager object the change of the user's location
|
|
552
443
|
*
|
|
553
|
-
* @param location new Location of the user. If null, nothing is done
|
|
554
|
-
* @param success callback to use when the navigation updates
|
|
555
|
-
* @param error callback to use when an error on navigation udpates raises
|
|
444
|
+
* @param location new {@link Location} of the user. If null, nothing is done
|
|
556
445
|
*/
|
|
557
|
-
updateNavigationWithLocation:
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
if (navigationSubscriptions.length === 0) {
|
|
563
|
-
error("No active navigation!!");
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
446
|
+
static updateNavigationWithLocation = (location: Location) => {
|
|
447
|
+
return exceptionWrapper<void>(({ onSuccess, onError }) => {
|
|
448
|
+
if (!SitumPlugin.navigationIsRunning()) {
|
|
449
|
+
throw "Situm > hook > No active navigation";
|
|
450
|
+
}
|
|
566
451
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
error || logError
|
|
571
|
-
);
|
|
572
|
-
},
|
|
452
|
+
RNCSitumPlugin.updateNavigationWithLocation(location, onSuccess, onError);
|
|
453
|
+
});
|
|
454
|
+
};
|
|
573
455
|
|
|
574
456
|
/**
|
|
575
457
|
* Removes all location updates. This removes the internal state of the manager,
|
|
576
458
|
* including the listener provided in requestNavigationUpdates(NavigationRequest,
|
|
577
459
|
* NavigationListener), so it won't receive more progress updates.
|
|
578
460
|
*
|
|
579
|
-
* @param callback
|
|
580
461
|
*/
|
|
581
|
-
removeNavigationUpdates
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
462
|
+
static removeNavigationUpdates = () => {
|
|
463
|
+
return exceptionWrapper<void>(({ onCallback }) => {
|
|
464
|
+
if (!SitumPlugin.navigationIsRunning()) {
|
|
465
|
+
throw "Situm > hook > Navigation updates were not active.";
|
|
466
|
+
}
|
|
585
467
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
error?: (event: any) => void,
|
|
593
|
-
options?: any
|
|
594
|
-
) {
|
|
595
|
-
RNCSitumPlugin.requestRealTimeUpdates(options || {});
|
|
596
|
-
realtimeSubscriptions.push([
|
|
597
|
-
SitumPluginEventEmitter.addListener("realtimeUpdated", navigationUpdates),
|
|
598
|
-
error
|
|
599
|
-
? SitumPluginEventEmitter.addListener(
|
|
600
|
-
"realtimeError",
|
|
601
|
-
error || logError
|
|
602
|
-
)
|
|
603
|
-
: null,
|
|
604
|
-
]);
|
|
605
|
-
},
|
|
468
|
+
navigationRunning = false;
|
|
469
|
+
RNCSitumPlugin.removeNavigationUpdates((reponse) => {
|
|
470
|
+
onCallback(reponse, "Failed to remove navigation updates");
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
};
|
|
606
474
|
|
|
607
475
|
/**
|
|
608
476
|
* Requests a real time devices positions
|
|
@@ -611,50 +479,173 @@ export default {
|
|
|
611
479
|
* @param error callback to use when an error on navigation udpates raises
|
|
612
480
|
* @param options Represents the configuration for getting realtime devices positions in
|
|
613
481
|
*/
|
|
614
|
-
removeRealTimeUpdates: function (_callback?: Function) {
|
|
615
|
-
realtimeSubscriptions = [];
|
|
616
|
-
RNCSitumPlugin.removeRealTimeUpdates();
|
|
617
|
-
},
|
|
618
482
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
483
|
+
static requestRealTimeUpdates = (
|
|
484
|
+
realtimeUpdates: (event: any) => void,
|
|
485
|
+
error?: (event: any) => void,
|
|
486
|
+
options?: any
|
|
487
|
+
) => {
|
|
488
|
+
return exceptionWrapper<void>(() => {
|
|
489
|
+
RNCSitumPlugin.requestRealTimeUpdates(options || {});
|
|
490
|
+
realtimeSubscriptions.push([
|
|
491
|
+
SitumPluginEventEmitter.addListener("realtimeUpdated", realtimeUpdates),
|
|
492
|
+
error
|
|
493
|
+
? SitumPluginEventEmitter.addListener(
|
|
494
|
+
"realtimeError",
|
|
495
|
+
error || logError
|
|
496
|
+
)
|
|
497
|
+
: null,
|
|
498
|
+
]);
|
|
499
|
+
});
|
|
500
|
+
};
|
|
624
501
|
|
|
502
|
+
/**
|
|
503
|
+
* Removes all real time updates listners.
|
|
504
|
+
*
|
|
505
|
+
* @param _callback
|
|
506
|
+
*/
|
|
507
|
+
static removeRealTimeUpdates = (_callback?: Function) => {
|
|
508
|
+
return exceptionWrapper<void>(() => {
|
|
509
|
+
realtimeSubscriptions = [];
|
|
510
|
+
RNCSitumPlugin.removeRealTimeUpdates();
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Checks if a point is inside a {@link Geofence}
|
|
516
|
+
*
|
|
517
|
+
*/
|
|
518
|
+
static checkIfPointInsideGeofence = (
|
|
519
|
+
request: any,
|
|
520
|
+
callback?: (response: { isInsideGeofence: boolean; geofence: any }) => void
|
|
521
|
+
) => {
|
|
625
522
|
RNCSitumPlugin.checkIfPointInsideGeofence(request, callback);
|
|
626
|
-
}
|
|
523
|
+
};
|
|
627
524
|
|
|
628
525
|
/**
|
|
629
|
-
* Callback that notifies when the user enters a
|
|
526
|
+
* Callback that notifies when the user enters a {@link Geofence}.
|
|
630
527
|
*
|
|
631
528
|
* In order to use correctly these callbacks you must know the following:
|
|
632
529
|
* - Positioning geofences (with trainer_metadata custom field) won't be notified.
|
|
633
530
|
* - These callbacks only work with indoor locations. Any outdoor location will
|
|
634
531
|
* produce a call to onExitedGeofences with the last positioned geofences as argument.
|
|
635
532
|
*
|
|
636
|
-
* @param callback the function called when the user enters a
|
|
533
|
+
* @param callback the function called when the user enters a {@link Geofence}
|
|
637
534
|
*/
|
|
638
|
-
onEnterGeofences
|
|
535
|
+
static onEnterGeofences = (callback: (event: Geofence) => void) => {
|
|
639
536
|
RNCSitumPlugin.onEnterGeofences();
|
|
640
537
|
// Adopts SDK behavior (setter):
|
|
641
|
-
SitumPluginEventEmitter.removeAllListeners("onEnterGeofences");
|
|
642
538
|
SitumPluginEventEmitter.addListener("onEnterGeofences", callback);
|
|
643
|
-
}
|
|
539
|
+
};
|
|
644
540
|
|
|
645
541
|
/**
|
|
646
|
-
* Callback that notifies when the user exits a
|
|
542
|
+
* Callback that notifies when the user exits a {@link Geofence}.
|
|
647
543
|
*
|
|
648
544
|
* In order to use correctly these callbacks you must know the following:
|
|
649
545
|
* - Positioning geofences (with trainer_metadata custom field) won't be notified.
|
|
650
546
|
* - These callbacks only work with indoor locations. Any outdoor location will
|
|
651
547
|
* produce a call to onExitedGeofences with the last positioned geofences as argument.
|
|
652
548
|
*
|
|
653
|
-
* @param callback the function called when the user exits a
|
|
549
|
+
* @param callback the function called when the user exits a {@link Geofence}
|
|
654
550
|
*/
|
|
655
|
-
onExitGeofences
|
|
551
|
+
static onExitGeofences = (callback: (event: Geofence) => void) => {
|
|
656
552
|
RNCSitumPlugin.onExitGeofences();
|
|
657
|
-
SitumPluginEventEmitter.removeAllListeners("onExitGeofences");
|
|
658
553
|
SitumPluginEventEmitter.addListener("onExitGeofences", callback);
|
|
659
|
-
}
|
|
660
|
-
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Callback that notifies when the user {@link Location} changes.
|
|
558
|
+
*
|
|
559
|
+
* @param callback the function called when the user {@link Location} changes
|
|
560
|
+
*/
|
|
561
|
+
static onLocationUpdate = (callback: (location: Location) => void) => {
|
|
562
|
+
SitumPluginEventEmitter.addListener("locationChanged", callback);
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Callback that notifies when the user {@link LocationStatus} changes.
|
|
567
|
+
*
|
|
568
|
+
* @param callback the function called when the user {@link LocationStatus} changes
|
|
569
|
+
*/
|
|
570
|
+
static onLocationStatus = (callback: (status: LocationStatus) => void) => {
|
|
571
|
+
SitumPluginEventEmitter.addListener("statusChanged", callback);
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Callback that notifies when there is an error while the user is positioining.
|
|
576
|
+
*
|
|
577
|
+
* @param callback the function called when there is an error
|
|
578
|
+
*/
|
|
579
|
+
static onLocationError = (callback: (status: Error) => void) => {
|
|
580
|
+
SitumPluginEventEmitter.addListener("locationError", callback);
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Callback that notifies when the user stops positioning.
|
|
585
|
+
*
|
|
586
|
+
* @param callback the function called when the user stops positioning.
|
|
587
|
+
*/
|
|
588
|
+
static onLocationStopped = (callback: () => void) => {
|
|
589
|
+
SitumPluginEventEmitter.addListener("locationStopped", callback);
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Callback that notifies every navigation progress.
|
|
594
|
+
*
|
|
595
|
+
* @param callback the function called when there is a navigation progress.
|
|
596
|
+
*/
|
|
597
|
+
static onNavigationProgress = (
|
|
598
|
+
callback: (progress: NavigationProgress) => void
|
|
599
|
+
) => {
|
|
600
|
+
SitumPluginEventEmitter.addListener(
|
|
601
|
+
"navigationUpdated",
|
|
602
|
+
(progress: NavigationProgress) => {
|
|
603
|
+
if (progress.type === SdkNavigationUpdateType.PROGRESS) {
|
|
604
|
+
callback(progress);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
);
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Callback that notifies when the user gets out of the current route
|
|
612
|
+
*
|
|
613
|
+
* @param callback the function called when the user gets out of the current route.
|
|
614
|
+
*/
|
|
615
|
+
static onNavigationOutOfRoute = (callback: () => void) => {
|
|
616
|
+
SitumPluginEventEmitter.addListener(
|
|
617
|
+
"navigationUpdated",
|
|
618
|
+
(progress: NavigationProgress) => {
|
|
619
|
+
if (progress.type === SdkNavigationUpdateType.OUT_OF_ROUTE) {
|
|
620
|
+
// TODO: maybe this causes the navigation to not work on oor?
|
|
621
|
+
callback();
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
);
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Callback that notifies when the user finishes the route.
|
|
629
|
+
*
|
|
630
|
+
* @param callback the function called when the user finishes the route.
|
|
631
|
+
*/
|
|
632
|
+
static onNavigationFinished = (callback: () => void) => {
|
|
633
|
+
SitumPluginEventEmitter.addListener(
|
|
634
|
+
"navigationUpdated",
|
|
635
|
+
(progress: NavigationProgress) => {
|
|
636
|
+
if (progress.type === SdkNavigationUpdateType.FINISHED) {
|
|
637
|
+
callback();
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
);
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Callback that notifies when there is an error during navigation.
|
|
645
|
+
*
|
|
646
|
+
* @param callback the function called when there is an error during navigation.
|
|
647
|
+
*/
|
|
648
|
+
static onNavigationError = (callback: (error: any) => void) => {
|
|
649
|
+
SitumPluginEventEmitter.addListener("navigationError", callback);
|
|
650
|
+
};
|
|
651
|
+
}
|