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