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