@situm/react-native 3.15.0-beta.1 → 3.15.0-beta.2

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.
Files changed (145) hide show
  1. package/android/src/main/java/com/situm/plugin/PluginHelper.java +1 -1
  2. package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +1 -1
  3. package/ios/SitumPlugin.m +14 -7
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/package.json +1 -0
  6. package/lib/commonjs/sdk/index.js.map +1 -1
  7. package/lib/commonjs/sdk/internaDelegatedState.js.map +1 -0
  8. package/lib/commonjs/sdk/nativeInterface.js.map +1 -1
  9. package/lib/commonjs/sdk/types/constants.js.map +1 -1
  10. package/lib/commonjs/sdk/types/index.js.map +1 -1
  11. package/lib/commonjs/sdk/utils.js.map +1 -1
  12. package/lib/commonjs/utils/index.js.map +1 -1
  13. package/lib/commonjs/utils/logError.js.map +1 -1
  14. package/lib/commonjs/wayfinding/index.js.map +1 -1
  15. package/lib/commonjs/wayfinding/types/index.js.map +1 -1
  16. package/lib/commonjs/wayfinding/utils/index.js.map +1 -1
  17. package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -1
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/module/package.json +1 -0
  20. package/lib/module/sdk/index.js.map +0 -1
  21. package/lib/module/sdk/internaDelegatedState.js.map +1 -0
  22. package/lib/module/sdk/nativeInterface.js.map +1 -1
  23. package/lib/module/sdk/types/constants.js.map +1 -1
  24. package/lib/module/sdk/types/index.js.map +1 -1
  25. package/lib/module/sdk/utils.js.map +1 -1
  26. package/lib/module/utils/index.js.map +1 -1
  27. package/lib/module/utils/logError.js.map +0 -1
  28. package/lib/module/wayfinding/index.js.map +1 -1
  29. package/lib/module/wayfinding/types/constants.js.map +1 -1
  30. package/lib/module/wayfinding/types/index.js.map +0 -1
  31. package/lib/module/wayfinding/utils/index.js.map +1 -1
  32. package/lib/module/wayfinding/utils/mapper.js.map +1 -1
  33. package/lib/typescript/index.d.ts.map +1 -0
  34. package/lib/typescript/{src/sdk → sdk}/index.d.ts +25 -32
  35. package/lib/typescript/sdk/index.d.ts.map +1 -0
  36. package/lib/typescript/sdk/internaDelegatedState.d.ts +17 -0
  37. package/lib/typescript/sdk/internaDelegatedState.d.ts.map +1 -0
  38. package/lib/typescript/{src/sdk → sdk}/nativeInterface.d.ts +4 -2
  39. package/lib/typescript/sdk/nativeInterface.d.ts.map +1 -0
  40. package/lib/typescript/sdk/types/constants.d.ts.map +1 -0
  41. package/lib/typescript/{src/sdk → sdk}/types/index.d.ts +2 -1
  42. package/lib/typescript/sdk/types/index.d.ts.map +1 -0
  43. package/lib/typescript/{src/sdk → sdk}/utils.d.ts +1 -1
  44. package/lib/typescript/sdk/utils.d.ts.map +1 -0
  45. package/lib/typescript/utils/index.d.ts.map +1 -0
  46. package/lib/typescript/utils/logError.d.ts.map +1 -0
  47. package/lib/typescript/{src/wayfinding → wayfinding}/components/MapView.d.ts +1 -1
  48. package/lib/typescript/wayfinding/components/MapView.d.ts.map +1 -0
  49. package/lib/typescript/wayfinding/hooks/index.d.ts.map +1 -0
  50. package/lib/typescript/wayfinding/index.d.ts.map +1 -0
  51. package/lib/typescript/{src/wayfinding → wayfinding}/store/index.d.ts +13 -13
  52. package/lib/typescript/wayfinding/store/index.d.ts.map +1 -0
  53. package/lib/typescript/{src/wayfinding → wayfinding}/store/utils.d.ts +0 -1
  54. package/lib/typescript/wayfinding/store/utils.d.ts.map +1 -0
  55. package/lib/typescript/wayfinding/types/constants.d.ts.map +1 -0
  56. package/lib/typescript/{src/wayfinding → wayfinding}/types/index.d.ts +1 -1
  57. package/lib/typescript/wayfinding/types/index.d.ts.map +1 -0
  58. package/lib/typescript/wayfinding/utils/index.d.ts +3 -0
  59. package/lib/typescript/wayfinding/utils/index.d.ts.map +1 -0
  60. package/lib/typescript/wayfinding/utils/mapper.d.ts.map +1 -0
  61. package/package.json +24 -35
  62. package/src/sdk/index.ts +67 -52
  63. package/src/sdk/internaDelegatedState.ts +54 -0
  64. package/src/sdk/nativeInterface.ts +31 -27
  65. package/src/sdk/types/index.ts +7 -6
  66. package/src/sdk/utils.ts +12 -9
  67. package/src/utils/logError.ts +1 -1
  68. package/src/wayfinding/components/MapView.tsx +103 -104
  69. package/src/wayfinding/hooks/index.ts +94 -91
  70. package/src/wayfinding/store/index.tsx +4 -4
  71. package/src/wayfinding/types/index.ts +1 -1
  72. package/src/wayfinding/utils/index.ts +2 -1
  73. package/LICENSE +0 -21
  74. package/README.md +0 -200
  75. package/SECURITY-POLICY.md +0 -9
  76. package/lib/commonjs/index.js +0 -73
  77. package/lib/commonjs/sdk/index.js +0 -932
  78. package/lib/commonjs/sdk/nativeInterface.js +0 -20
  79. package/lib/commonjs/sdk/types/constants.js +0 -68
  80. package/lib/commonjs/sdk/types/index.js +0 -405
  81. package/lib/commonjs/sdk/utils.js +0 -156
  82. package/lib/commonjs/utils/index.js +0 -17
  83. package/lib/commonjs/utils/logError.js +0 -21
  84. package/lib/commonjs/wayfinding/components/MapView.js +0 -389
  85. package/lib/commonjs/wayfinding/components/MapView.js.map +0 -1
  86. package/lib/commonjs/wayfinding/hooks/index.js +0 -229
  87. package/lib/commonjs/wayfinding/hooks/index.js.map +0 -1
  88. package/lib/commonjs/wayfinding/index.js +0 -57
  89. package/lib/commonjs/wayfinding/store/index.js +0 -242
  90. package/lib/commonjs/wayfinding/store/index.js.map +0 -1
  91. package/lib/commonjs/wayfinding/store/utils.js +0 -49
  92. package/lib/commonjs/wayfinding/store/utils.js.map +0 -1
  93. package/lib/commonjs/wayfinding/types/constants.js +0 -13
  94. package/lib/commonjs/wayfinding/types/constants.js.map +0 -1
  95. package/lib/commonjs/wayfinding/types/index.js +0 -6
  96. package/lib/commonjs/wayfinding/utils/index.js +0 -11
  97. package/lib/commonjs/wayfinding/utils/mapper.js +0 -206
  98. package/lib/module/index.js +0 -12
  99. package/lib/module/sdk/index.js +0 -903
  100. package/lib/module/sdk/nativeInterface.js +0 -18
  101. package/lib/module/sdk/types/constants.js +0 -63
  102. package/lib/module/sdk/types/index.js +0 -434
  103. package/lib/module/sdk/utils.js +0 -144
  104. package/lib/module/utils/index.js +0 -2
  105. package/lib/module/utils/logError.js +0 -15
  106. package/lib/module/wayfinding/components/MapView.js +0 -379
  107. package/lib/module/wayfinding/components/MapView.js.map +0 -1
  108. package/lib/module/wayfinding/hooks/index.js +0 -220
  109. package/lib/module/wayfinding/hooks/index.js.map +0 -1
  110. package/lib/module/wayfinding/index.js +0 -13
  111. package/lib/module/wayfinding/store/index.js +0 -206
  112. package/lib/module/wayfinding/store/index.js.map +0 -1
  113. package/lib/module/wayfinding/store/utils.js +0 -38
  114. package/lib/module/wayfinding/store/utils.js.map +0 -1
  115. package/lib/module/wayfinding/types/constants.js +0 -7
  116. package/lib/module/wayfinding/types/index.js +0 -2
  117. package/lib/module/wayfinding/utils/index.js +0 -4
  118. package/lib/module/wayfinding/utils/mapper.js +0 -195
  119. package/lib/typescript/src/index.d.ts.map +0 -1
  120. package/lib/typescript/src/sdk/index.d.ts.map +0 -1
  121. package/lib/typescript/src/sdk/nativeInterface.d.ts.map +0 -1
  122. package/lib/typescript/src/sdk/types/constants.d.ts.map +0 -1
  123. package/lib/typescript/src/sdk/types/index.d.ts.map +0 -1
  124. package/lib/typescript/src/sdk/utils.d.ts.map +0 -1
  125. package/lib/typescript/src/utils/index.d.ts.map +0 -1
  126. package/lib/typescript/src/utils/logError.d.ts.map +0 -1
  127. package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +0 -1
  128. package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +0 -1
  129. package/lib/typescript/src/wayfinding/index.d.ts.map +0 -1
  130. package/lib/typescript/src/wayfinding/store/index.d.ts.map +0 -1
  131. package/lib/typescript/src/wayfinding/store/utils.d.ts.map +0 -1
  132. package/lib/typescript/src/wayfinding/types/constants.d.ts.map +0 -1
  133. package/lib/typescript/src/wayfinding/types/index.d.ts.map +0 -1
  134. package/lib/typescript/src/wayfinding/utils/index.d.ts +0 -3
  135. package/lib/typescript/src/wayfinding/utils/index.d.ts.map +0 -1
  136. package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +0 -1
  137. package/security.txt +0 -4
  138. /package/lib/typescript/{src/index.d.ts → index.d.ts} +0 -0
  139. /package/lib/typescript/{src/sdk → sdk}/types/constants.d.ts +0 -0
  140. /package/lib/typescript/{src/utils → utils}/index.d.ts +0 -0
  141. /package/lib/typescript/{src/utils → utils}/logError.d.ts +0 -0
  142. /package/lib/typescript/{src/wayfinding → wayfinding}/hooks/index.d.ts +0 -0
  143. /package/lib/typescript/{src/wayfinding → wayfinding}/index.d.ts +0 -0
  144. /package/lib/typescript/{src/wayfinding → wayfinding}/types/constants.d.ts +0 -0
  145. /package/lib/typescript/{src/wayfinding → wayfinding}/utils/mapper.d.ts +0 -0
@@ -1,903 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* eslint-disable @typescript-eslint/ban-types */
3
-
4
- import { NativeEventEmitter, NativeModules, Platform } from "react-native";
5
- import packageJson from "../../package.json";
6
- import { logError } from "../utils/logError";
7
- import { ErrorCode, ErrorType, InternalCall } from "./types";
8
- import { InternalCallType, SdkNavigationUpdateType } from "./types/constants";
9
- import { exceptionWrapper, locationErrorAdapter, locationStatusAdapter, promiseWrapper } from "./utils";
10
- export * from "./types";
11
- export * from "./types/constants";
12
- const LINKING_ERROR = `The package 'react-native' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
13
- ios: "- You have run 'pod install'\n",
14
- default: ""
15
- }) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo managed workflow\n";
16
- const RNCSitumPlugin = NativeModules.RNCSitumPlugin || new Proxy({}, {
17
- get() {
18
- throw new Error(LINKING_ERROR);
19
- }
20
- });
21
- const SitumPluginEventEmitter = new NativeEventEmitter(RNCSitumPlugin);
22
-
23
- // TODO: these do not act as state, not reliable
24
- let positioningRunning = false;
25
- let navigationRunning = false;
26
- let realtimeSubscriptions = [];
27
- let internalMethodCallMapDelegate = _ => {
28
- // internalMethodCallMapDelegate is an empty function by default.
29
- };
30
-
31
- // TODO: For now, I am keeping this behavior as it was, but it seems like a candidate for refactoring.
32
- const locationCallbackForNavigation = loc => {
33
- if (!SitumPlugin.navigationIsRunning()) return;
34
- SitumPlugin.updateNavigationWithLocation(loc);
35
- };
36
-
37
- // Client callbacks:
38
- /* eslint-disable @typescript-eslint/no-empty-function */
39
-
40
- let locationCallback = _ => {};
41
- let locationStatusCallback = _ => {};
42
- let locationStoppedCallback = () => {};
43
- let locationErrorCallback = _ => {};
44
- let navigationStartedCallback = _ => {};
45
- let navigationProgressCallback = _ => {};
46
- let navigationDestinationReachedCallback = _ => {};
47
- let navigationOutOfRouteCallback = () => {};
48
- let navigationFinishedCallback = () => {}; // Deprecated!
49
- let navigationCancellationCallback = () => {};
50
- let navigationErrorCallback = _ => {};
51
- let enterGeofencesCallback = _ => {};
52
- let exitGeofencesCallback = _ => {};
53
-
54
- /* eslint-enable @typescript-eslint/no-empty-function */
55
-
56
- // Internal callbacks:
57
- // These callback functions will be added as listeners to SitumPluginEventEmitter as soon as possible and will be
58
- // listening events for all the plugin lifecycle. They will forward calls to both client callbacks and the MapView
59
- // internal callback.
60
-
61
- const _internalLocationCallback = loc => {
62
- // MapView internal callback:
63
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.LOCATION, loc));
64
- // Navigation internal callback: TODO review this, seems to be different to other plugins and candidate for refactoring.
65
- locationCallbackForNavigation(loc);
66
- // Client callback:
67
- locationCallback(loc);
68
- };
69
- const _internalLocationStatusCallback = status => {
70
- var _locationStatusCallba;
71
- const mapViewStatusName = locationStatusAdapter(status.statusName);
72
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.LOCATION_STATUS, mapViewStatusName));
73
- // TODO: we are delegating different values to the internal and client callbacks. The viewer only understands
74
- // the states defined in LocationStatusName, but the integrator might be interested in any state from the SDK.
75
- (_locationStatusCallba = locationStatusCallback) === null || _locationStatusCallba === void 0 || _locationStatusCallba(status);
76
- };
77
- const _internalLocationStoppedCallback = () => {
78
- var _locationStoppedCallb;
79
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.LOCATION_STOPPED, undefined));
80
- // TODO: this callback is used only in RN, delete!
81
- (_locationStoppedCallb = locationStoppedCallback) === null || _locationStoppedCallb === void 0 || _locationStoppedCallb();
82
- };
83
- const _internalLocationErrorCallback = error => {
84
- var _locationErrorCallbac;
85
- const adaptedError = locationErrorAdapter(error);
86
- if (adaptedError.type === ErrorType.CRITICAL) SitumPlugin.removeLocationUpdates();
87
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.LOCATION_ERROR, adaptedError));
88
- (_locationErrorCallbac = locationErrorCallback) === null || _locationErrorCallbac === void 0 || _locationErrorCallbac(adaptedError);
89
- };
90
- const _internalNavigationStartedCallback = route => {
91
- var _navigationStartedCal;
92
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.NAVIGATION_START, route));
93
- (_navigationStartedCal = navigationStartedCallback) === null || _navigationStartedCal === void 0 || _navigationStartedCal(route);
94
- };
95
- const _internalNavigationProgressCallback = progress => {
96
- var _navigationProgressCa;
97
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.NAVIGATION_PROGRESS, progress));
98
- (_navigationProgressCa = navigationProgressCallback) === null || _navigationProgressCa === void 0 || _navigationProgressCa(progress);
99
- };
100
- const _internalNavigationDestinationReachedCallback = route => {
101
- var _navigationDestinatio;
102
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.NAVIGATION_DESTINATION_REACHED, route));
103
- (_navigationDestinatio = navigationDestinationReachedCallback) === null || _navigationDestinatio === void 0 || _navigationDestinatio(route);
104
- };
105
- const _internalNavigationOutOfRouteCallback = () => {
106
- var _navigationOutOfRoute;
107
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.NAVIGATION_OUT_OF_ROUTE, undefined));
108
- (_navigationOutOfRoute = navigationOutOfRouteCallback) === null || _navigationOutOfRoute === void 0 || _navigationOutOfRoute();
109
- };
110
- const _internalNavigationFinishedCallback = () => {
111
- var _navigationFinishedCa;
112
- // Deprecated!
113
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.NAVIGATION_CANCELLATION, undefined));
114
- (_navigationFinishedCa = navigationFinishedCallback) === null || _navigationFinishedCa === void 0 || _navigationFinishedCa();
115
- };
116
- const _internalNavigationCancellationCallback = () => {
117
- var _navigationCancellati;
118
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.NAVIGATION_CANCELLATION, undefined));
119
- (_navigationCancellati = navigationCancellationCallback) === null || _navigationCancellati === void 0 || _navigationCancellati();
120
- };
121
- const _internalNavigationErrorCallback = error => {
122
- var _navigationErrorCallb;
123
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.NAVIGATION_ERROR, error));
124
- (_navigationErrorCallb = navigationErrorCallback) === null || _navigationErrorCallb === void 0 || _navigationErrorCallb(error);
125
- };
126
- const _internalEnterGeofencesCallback = data => {
127
- var _enterGeofencesCallba;
128
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.GEOFENCES_ENTER, data));
129
- (_enterGeofencesCallba = enterGeofencesCallback) === null || _enterGeofencesCallba === void 0 || _enterGeofencesCallba(data);
130
- };
131
- const _internalExitGeofencesCallback = data => {
132
- var _exitGeofencesCallbac;
133
- internalMethodCallMapDelegate(new InternalCall(InternalCallType.GEOFENCES_EXIT, data));
134
- (_exitGeofencesCallbac = exitGeofencesCallback) === null || _exitGeofencesCallbac === void 0 || _exitGeofencesCallbac(data);
135
- };
136
- const _registerCallbacks = () => {
137
- const callbacksMap = {
138
- locationChanged: _internalLocationCallback,
139
- statusChanged: _internalLocationStatusCallback,
140
- locationStopped: _internalLocationStoppedCallback,
141
- locationError: _internalLocationErrorCallback,
142
- [SdkNavigationUpdateType.START]: _internalNavigationStartedCallback,
143
- [SdkNavigationUpdateType.PROGRESS]: _internalNavigationProgressCallback,
144
- [SdkNavigationUpdateType.DESTINATION_REACHED]: _internalNavigationDestinationReachedCallback,
145
- [SdkNavigationUpdateType.OUTSIDE_ROUTE]: _internalNavigationOutOfRouteCallback,
146
- [SdkNavigationUpdateType.FINISHED]: _internalNavigationFinishedCallback,
147
- [SdkNavigationUpdateType.CANCELLATION]: _internalNavigationCancellationCallback,
148
- [SdkNavigationUpdateType.ERROR]: _internalNavigationErrorCallback,
149
- onEnterGeofences: _internalEnterGeofencesCallback,
150
- onExitGeofences: _internalExitGeofencesCallback
151
- };
152
- Object.entries(callbacksMap).forEach(([eventName, callback]) => {
153
- SitumPluginEventEmitter.removeAllListeners(eventName);
154
- SitumPluginEventEmitter.addListener(eventName, callback);
155
- });
156
- };
157
-
158
- // End Internal callbacks --
159
-
160
- export default class SitumPlugin {
161
- /**
162
- * Whether the positioning is currently in execution.
163
- * @returns boolean
164
- */
165
- static positioningIsRunning = () => positioningRunning;
166
-
167
- /**
168
- * Whether the navigation is currently in execution.
169
- * @returns boolean
170
- */
171
- static navigationIsRunning = () => navigationRunning;
172
-
173
- /**
174
- * Initializes {@link SitumPlugin}.
175
- *
176
- * This method must be called before invoking any other methods.
177
- * This method can be safely called many times as it will only initialise the SDK
178
- * if it is not already initialised.
179
- *
180
- * @returns void
181
- * @throw Exception
182
- */
183
- static init = () => {
184
- _registerCallbacks();
185
- return exceptionWrapper(() => {
186
- RNCSitumPlugin.initSitumSDK();
187
- });
188
- };
189
-
190
- /**
191
- * Provides your API key to the Situm SDK.
192
- *
193
- * This key is generated for your application in the Dashboard.
194
- * Old credentials will be removed.
195
- *
196
- * @param apiKey user's apikey.
197
- *
198
- * @returns void
199
- * @throw Exception
200
- */
201
- static setApiKey = apiKey => {
202
- return exceptionWrapper(({
203
- onCallback
204
- }) => {
205
- RNCSitumPlugin.setApiKey("email@email.com", apiKey, response => {
206
- onCallback(response, "Failed to set API key.");
207
- });
208
- });
209
- };
210
-
211
- /**
212
- * Provides user's email and password. This credentials will be used to obtain a
213
- * valid user token to authenticate the server request, when necessary. Token
214
- * obtaining is not necessary done when this method is executed. Old credentials
215
- * will be removed.
216
- *
217
- * @param email user's email.
218
- * @param password user's password.
219
- *
220
- * @returns void
221
- * @throw Exception
222
- */
223
- static setUserPass = (email, password) => {
224
- return exceptionWrapper(({
225
- onCallback
226
- }) => {
227
- RNCSitumPlugin.setUserPass(email, password, response => {
228
- onCallback(response, "Failed to set user credentials.");
229
- });
230
- });
231
- };
232
-
233
- /**
234
- * Sets the API's base URL to retrieve the data.
235
- *
236
- * @param url user's email.
237
- *
238
- * @returns void
239
- * @throw Exception
240
- */
241
-
242
- static setDashboardURL = url => {
243
- return exceptionWrapper(({
244
- onCallback
245
- }) => {
246
- RNCSitumPlugin.setDashboardURL(url, response => {
247
- onCallback(response, "Failed to set dashboard URL.");
248
- });
249
- });
250
- };
251
-
252
- /**
253
- * Set to true if you want the SDK to download the configuration from the Situm API
254
- * and use it by default. Right now it only affects the {@link LocationRequest}.
255
- * Default value is true from SDK version 2.83.5
256
- *
257
- * @param useRemoteConfig
258
- *
259
- * @returns void
260
- * @throw Exception
261
- */
262
- static setUseRemoteConfig = useRemoteConfig => {
263
- return exceptionWrapper(({
264
- onCallback
265
- }) => {
266
- RNCSitumPlugin.setUseRemoteConfig(useRemoteConfig ? "true" : "false", response => {
267
- onCallback(response, "Failed to set remote config");
268
- });
269
- });
270
- };
271
-
272
- /**
273
- * Sets the max seconds the cache is valid
274
- *
275
- * @returns void
276
- * @throw Exception
277
- */
278
- static setMaxCacheAge = cacheAge => {
279
- return exceptionWrapper(({
280
- onCallback
281
- }) => {
282
- RNCSitumPlugin.setCacheMaxAge(cacheAge, response => {
283
- onCallback(response, "Failed to set cache max age");
284
- });
285
- });
286
- };
287
-
288
- /**
289
- * Sets the SDK {@link ConfigurationOptions}.
290
- *
291
- * @param options {@link ConfigurationOptions}
292
- *
293
- * @returns void
294
- * @throw Exception
295
- */
296
- static setConfiguration = options => {
297
- return exceptionWrapper(() => {
298
- if (options.useRemoteConfig !== undefined) {
299
- SitumPlugin.setUseRemoteConfig(options.useRemoteConfig);
300
- }
301
- if (options.cacheMaxAge !== undefined) {
302
- SitumPlugin.setMaxCacheAge(options.cacheMaxAge);
303
- }
304
-
305
- // Handle rest of configuration options
306
- });
307
- };
308
-
309
- /**
310
- * Invalidate all the resources in the cache
311
- *
312
- * @returns void
313
- * @throw Exception
314
- */
315
- static invalidateCache = () => {
316
- return exceptionWrapper(() => {
317
- RNCSitumPlugin.invalidateCache();
318
- });
319
- };
320
-
321
- /**
322
- * Gets the list of versions for the current plugin and environment
323
- *
324
- * @returns void
325
- * @throw Exception
326
- */
327
- static sdkVersion = () => {
328
- return exceptionWrapper(({
329
- onSuccess
330
- }) => {
331
- const versions = {
332
- react_native: packageJson.version
333
- };
334
- if (Platform.OS === "ios") {
335
- versions.ios = packageJson.sdkVersions.ios;
336
- } else {
337
- versions.android = packageJson.sdkVersions.android;
338
- }
339
- onSuccess(versions);
340
- });
341
- };
342
-
343
- /**
344
- * Returns the device identifier that has generated the location
345
- */
346
- static getDeviceId = () => {
347
- return promiseWrapper(({
348
- onSuccess,
349
- onError
350
- }) => {
351
- RNCSitumPlugin.getDeviceId(response => {
352
- //@ts-ignore
353
- if (response !== null && response !== void 0 && response.deviceId) {
354
- // Resolve with the actual deviceId
355
- //@ts-ignore
356
- onSuccess(response.deviceId);
357
- } else {
358
- // Reject if deviceId is not available in the response
359
- onError({
360
- code: ErrorCode.UNKNOWN,
361
- message: "Couldn't get device ID",
362
- type: ErrorType.CRITICAL
363
- });
364
- }
365
- });
366
- });
367
- };
368
-
369
- /**
370
- * Downloads all the {@link Building}s for the current user.
371
- */
372
- static fetchBuildings = () => {
373
- return promiseWrapper(({
374
- onSuccess,
375
- onError
376
- }) => {
377
- RNCSitumPlugin.fetchBuildings(onSuccess, onError);
378
- });
379
- };
380
-
381
- /**
382
- * Downloads all the building data for the selected building. This info includes
383
- * {@link Floor}, indoor and outdoor {@link Poi}s, events and paths. Also it download floor
384
- * maps and {@link PoiCategory} icons to local storage.
385
- *
386
- * @param building {@link Building}
387
- */
388
- static fetchBuildingInfo = building => {
389
- return promiseWrapper(({
390
- onSuccess,
391
- onError
392
- }) => {
393
- RNCSitumPlugin.fetchBuildingInfo(building, onSuccess, onError);
394
- });
395
- };
396
-
397
- /**
398
- * (Experimental) Downloads the tiled-map of a certain building
399
- *
400
- * @param building {@link Building} whose tiles will be downloaded
401
- */
402
- static fetchTilesFromBuilding = building => {
403
- return promiseWrapper(({
404
- onSuccess,
405
- onError
406
- }) => {
407
- RNCSitumPlugin.fetchTilesFromBuilding(building, onSuccess, onError);
408
- });
409
- };
410
-
411
- /**
412
- * Downloads all the floors of a building
413
- *
414
- * @param building {@link Building}
415
- */
416
- static fetchFloorsFromBuilding = building => {
417
- return promiseWrapper(({
418
- onSuccess,
419
- onError
420
- }) => {
421
- RNCSitumPlugin.fetchFloorsFromBuilding(building, onSuccess, onError);
422
- });
423
- };
424
-
425
- /**
426
- * Downloads the map image of a {@link Floor}
427
- *
428
- * @param floor {@link Floor}
429
- */
430
- static fetchMapFromFloor = floor => {
431
- return promiseWrapper(({
432
- onSuccess,
433
- onError
434
- }) => {
435
- RNCSitumPlugin.fetchMapFromFloor(floor, onSuccess, onError);
436
- });
437
- };
438
-
439
- /**
440
- * Get the geofences of a {@link Building}
441
- *
442
- * @param building {@link Building}
443
- */
444
- static fetchGeofencesFromBuilding = building => {
445
- return promiseWrapper(({
446
- onSuccess,
447
- onError
448
- }) => {
449
- RNCSitumPlugin.fetchGeofencesFromBuilding(building, onSuccess, onError);
450
- });
451
- };
452
-
453
- /**
454
- * Get all {@link PoiCategory}, download and cache their icons asynchronously.
455
- */
456
- static fetchPoiCategories = () => {
457
- return promiseWrapper(({
458
- onSuccess,
459
- onError
460
- }) => {
461
- RNCSitumPlugin.fetchPoiCategories(onSuccess, onError);
462
- });
463
- };
464
-
465
- /**
466
- * Get the normal {@link PoiIcon} for a category
467
- *
468
- * @param category {@link PoiCategory}. Not null.
469
- */
470
- static fetchPoiCategoryIconNormal = category => {
471
- return promiseWrapper(({
472
- onSuccess,
473
- onError
474
- }) => {
475
- RNCSitumPlugin.fetchPoiCategoryIconNormal(category, onSuccess, onError);
476
- });
477
- };
478
-
479
- /**
480
- * Get the selected {@link PoiIcon} for a {@link PoiCategory}
481
- *
482
- * @param category {@link PoiCategory}. Not null.
483
- */
484
- static fetchPoiCategoryIconSelected = category => {
485
- return promiseWrapper(({
486
- onSuccess,
487
- onError
488
- }) => {
489
- RNCSitumPlugin.fetchPoiCategoryIconSelected(category, onSuccess, onError);
490
- });
491
- };
492
-
493
- /**
494
- * Download the indoor {@link Poi}s of a {@link Building}
495
- *
496
- * @param building {@link Building}
497
- */
498
- static fetchIndoorPOIsFromBuilding = building => {
499
- return promiseWrapper(({
500
- onSuccess,
501
- onError
502
- }) => {
503
- RNCSitumPlugin.fetchIndoorPOIsFromBuilding(building, onSuccess, onError);
504
- });
505
- };
506
-
507
- /**
508
- * Download the outdoor {@link Poi}s of a {@link Building}
509
- *
510
- * @param building {@link Building}
511
- */
512
- static fetchOutdoorPOIsFromBuilding = building => {
513
- return promiseWrapper(({
514
- onSuccess,
515
- onError
516
- }) => {
517
- RNCSitumPlugin.fetchOutdoorPOIsFromBuilding(building, onSuccess, onError);
518
- });
519
- };
520
-
521
- /**
522
- * Starts positioning.
523
- *
524
- * @param {LocationRequest} locationRequest Positioning options to configure how positioning will behave
525
- */
526
- static requestLocationUpdates = locationRequest => {
527
- return exceptionWrapper(() => {
528
- if (SitumPlugin.positioningIsRunning()) return;
529
- RNCSitumPlugin.startPositioning(locationRequest || {});
530
- positioningRunning = true;
531
- });
532
- };
533
-
534
- /**
535
- * Stops positioning, removing all location updates
536
- */
537
- static removeLocationUpdates = () => {
538
- return exceptionWrapper(() => {
539
- if (!SitumPlugin.positioningIsRunning()) return;
540
- RNCSitumPlugin.stopPositioning(response => {
541
- if (response.success) {
542
- positioningRunning = false;
543
- } else {
544
- throw "Situm > hook > Could not stop positioning";
545
- }
546
- });
547
- });
548
- };
549
-
550
- /**
551
- * Calculates a route between two points. The result is provided
552
- * asynchronously using the callback.
553
- *
554
- * @param building {@link Building}
555
- * @param from {@link Point} route origin
556
- * @param to {@link Point} route destination
557
- * @param directionOptions {@link DirectionsOptions}
558
- */
559
- static requestDirections = (building, from, to, directionOptions) => {
560
- return promiseWrapper(({
561
- onSuccess,
562
- onError
563
- }) => {
564
- const params = [building, from, to, directionOptions || {}];
565
- RNCSitumPlugin.requestDirections(params, onSuccess, onError);
566
- });
567
- };
568
-
569
- /**
570
- * Set the navigation params, and the listener that receives the updated
571
- * navigation progress.
572
- *
573
- * Can only exist one navigation with one listener at a time. If this method was
574
- * previously invoked, but removeLocationUpdates() wasn't, removeLocationUpdates()
575
- * is called internally.
576
- *
577
- * @param options {@link NavigationRequest}
578
- */
579
- static requestNavigationUpdates = options => {
580
- return exceptionWrapper(() => {
581
- RNCSitumPlugin.requestNavigationUpdates(options || {});
582
- navigationRunning = true;
583
- });
584
- };
585
-
586
- /**
587
- * Informs NavigationManager object the change of the user's location
588
- *
589
- * @param location new {@link Location} of the user. If null, nothing is done
590
- */
591
- static updateNavigationWithLocation = location => {
592
- return exceptionWrapper(({
593
- onSuccess,
594
- onError
595
- }) => {
596
- if (!SitumPlugin.navigationIsRunning()) {
597
- throw "Situm > hook > No active navigation";
598
- }
599
- RNCSitumPlugin.updateNavigationWithLocation(location, onSuccess, onError);
600
- });
601
- };
602
-
603
- /**
604
- * Removes all location updates. This removes the internal state of the manager,
605
- * including the listener provided in requestNavigationUpdates(NavigationRequest,
606
- * NavigationListener), so it won't receive more progress updates.
607
- *
608
- */
609
- static removeNavigationUpdates = () => {
610
- return promiseWrapper(({
611
- onCallback
612
- }) => {
613
- if (!SitumPlugin.navigationIsRunning()) return;
614
- navigationRunning = false;
615
- RNCSitumPlugin.removeNavigationUpdates(response => {
616
- onCallback(response, "Failed to remove navigation updates");
617
- });
618
- });
619
- };
620
-
621
- /**
622
- * Requests a real time devices positions
623
- *
624
- * @param realtimeUpdates callback to use when new device positions are updated
625
- * @param error callback to use when an error on navigation udpates raises
626
- * @param options Represents the configuration for getting realtime devices positions in
627
- */
628
-
629
- static requestRealTimeUpdates = (realtimeUpdates, error, options) => {
630
- return exceptionWrapper(() => {
631
- RNCSitumPlugin.requestRealTimeUpdates(options || {});
632
- realtimeSubscriptions.push([SitumPluginEventEmitter.addListener("realtimeUpdated", realtimeUpdates), error ? SitumPluginEventEmitter.addListener("realtimeError", error || logError) : null]);
633
- });
634
- };
635
-
636
- /**
637
- * Removes all real time updates listners.
638
- *
639
- * @param _callback
640
- */
641
- static removeRealTimeUpdates = _callback => {
642
- return exceptionWrapper(() => {
643
- realtimeSubscriptions = [];
644
- RNCSitumPlugin.removeRealTimeUpdates();
645
- });
646
- };
647
-
648
- /**
649
- * Checks if a point is inside a {@link Geofence}
650
- *
651
- */
652
- static checkIfPointInsideGeofence = (request, callback) => {
653
- RNCSitumPlugin.checkIfPointInsideGeofence(request, callback);
654
- };
655
-
656
- /**
657
- * INTERNAL METHOD.
658
- *
659
- * Update SDK with the viewer navigation states.
660
- * Do not use this method as it is intended for internal use
661
- * by the map viewer module.
662
- *
663
- * @param externalNavigation
664
- */
665
- static updateNavigationState = externalNavigation => {
666
- return exceptionWrapper(() => {
667
- RNCSitumPlugin.updateNavigationState(externalNavigation);
668
- });
669
- };
670
-
671
- /**
672
- * Automatically assists users in resolving app-related permission and sensor issues.
673
- *
674
- * This method tells the native SDKs to present a user interface that explains detected
675
- * configuration issues and guides users through the required steps to resolve them,
676
- * following best practices for runtime permission requests.
677
- *
678
- * Issues addressed include:
679
- * - Missing permissions for Location or Bluetooth.
680
- * - Disabled Location or Bluetooth sensors.
681
- *
682
- * Use the <code>userHelperOptions</code> parameter to configure the available options.
683
- * Call {@link enableUserHelper} as a shortcut to enable the user helper with default configuration.
684
- * Call {@link disableUserHelper} as a shortcut to disable the user helper.
685
- *
686
- * @param {UserHelperOptions} userHelperOptions - Options for the user helper.
687
- * @param {function} cb - Cordova native callback to receive data.
688
- * @param {function} error - Cordova native callback to receive errors.
689
- */
690
- static configureUserHelper = userHelperOptions => {
691
- _registerCallbacks();
692
- return exceptionWrapper(({
693
- onSuccess,
694
- onError
695
- }) => {
696
- RNCSitumPlugin.configureUserHelper(userHelperOptions, onSuccess, onError);
697
- });
698
- };
699
-
700
- /**
701
- * Enables the user helper.
702
- *
703
- * Shortcut for {@link configureUserHelper} with <code>{enabled: true}</code>.
704
- *
705
- * @param {function} cb - Cordova native callback to receive data.
706
- * @param {function} error - Cordova native callback to receive errors.
707
- */
708
- static enableUserHelper = () => {
709
- SitumPlugin.configureUserHelper({
710
- enabled: true,
711
- colorScheme: undefined
712
- });
713
- };
714
-
715
- /**
716
- * Disables the user helper.
717
- *
718
- * Shortcut for {@link configureUserHelper} with <code>{enabled: false}</code>.
719
- *
720
- * @param {function} cb - Cordova native callback to receive data.
721
- * @param {function} error - Cordova native callback to receive errors.
722
- */
723
- static disableUserHelper = () => {
724
- SitumPlugin.configureUserHelper({
725
- enabled: false,
726
- colorScheme: undefined
727
- });
728
- };
729
-
730
- /**
731
- * INTERNAL METHOD.
732
- *
733
- * Validate if the mapView internal settings have been properly configured
734
- * Do not use this method as it is intended for internal use
735
- * by the map viewer module.
736
- *
737
- * @param validateMapViewProjectSettings
738
- */
739
- static validateMapViewProjectSettings = () => {
740
- if (Platform.OS === "ios") {
741
- return exceptionWrapper(() => {
742
- RNCSitumPlugin.validateMapViewProjectSettings();
743
- });
744
- }
745
- };
746
-
747
- /**
748
- * INTERNAL METHOD.
749
- *
750
- * Set a native MethodCall delegate. Do not use this method as it is intended for internal use by the map viewer module.
751
- * @param callback
752
- */
753
- static internalSetMethodCallMapDelegate = callback => {
754
- internalMethodCallMapDelegate = callback;
755
- };
756
-
757
- //-----------------------------------------------------------------------------//
758
- //-----------------------------GEOFENCES CALLBACKS-----------------------------//
759
- //-----------------------------------------------------------------------------//
760
-
761
- /**
762
- * Callback that notifies when the user enters a {@link Geofence}.
763
- *
764
- * In order to use correctly these callbacks you must know the following:
765
- * - Positioning geofences (with trainer_metadata custom field) won't be notified.
766
- * - These callbacks only work with indoor locations. Any outdoor location will
767
- * produce a call to onExitedGeofences with the last positioned geofences as argument.
768
- *
769
- * @param callback the function called when the user enters a {@link Geofence}
770
- */
771
- static onEnterGeofences = callback => {
772
- RNCSitumPlugin.onEnterGeofences();
773
- // Adopts SDK behavior (setter):
774
- enterGeofencesCallback = callback;
775
- };
776
-
777
- /**
778
- * Callback that notifies when the user exits a {@link Geofence}.
779
- *
780
- * In order to use correctly these callbacks you must know the following:
781
- * - Positioning geofences (with trainer_metadata custom field) won't be notified.
782
- * - These callbacks only work with indoor locations. Any outdoor location will
783
- * produce a call to onExitedGeofences with the last positioned geofences as argument.
784
- *
785
- * @param callback the function called when the user exits a {@link Geofence}
786
- */
787
- static onExitGeofences = callback => {
788
- RNCSitumPlugin.onExitGeofences();
789
- exitGeofencesCallback = callback;
790
- };
791
-
792
- //-----------------------------------------------------------------------------//
793
- //-----------------------------LOCATION CALLBACKS------------------------------//
794
- //-----------------------------------------------------------------------------//
795
-
796
- /**
797
- * Callback that notifies when the user {@link Location} changes.
798
- *
799
- * @param callback the function called when the user {@link Location} changes
800
- */
801
- static onLocationUpdate = callback => {
802
- locationCallback = callback;
803
- };
804
-
805
- /**
806
- * Callback that notifies when the user {@link LocationStatus} changes.
807
- *
808
- * @param callback the function called when the user {@link LocationStatus} changes
809
- */
810
- static onLocationStatus = callback => {
811
- locationStatusCallback = callback;
812
- };
813
-
814
- /**
815
- * Callback that notifies when there is an error while the user is positioining.
816
- *
817
- * @param callback the function called when there is an error
818
- */
819
- static onLocationError = callback => {
820
- locationErrorCallback = callback;
821
- };
822
-
823
- /**
824
- * Callback that notifies when the user stops positioning.
825
- *
826
- * @param callback the function called when the user stops positioning.
827
- */
828
- static onLocationStopped = callback => {
829
- locationStoppedCallback = callback;
830
- };
831
-
832
- //-----------------------------------------------------------------------------//
833
- //-----------------------------NAVIGATION CALLBACKS----------------------------//
834
- //-----------------------------------------------------------------------------//
835
-
836
- /**
837
- * Callback that notifies when navigation starts.
838
- *
839
- * @param callback a function that returns the initial {@link Route} by parameters.
840
- */
841
- static onNavigationStart = callback => {
842
- navigationStartedCallback = callback;
843
- };
844
-
845
- /**
846
- * Callback that notifies every progress the user makes while navigating.
847
- *
848
- * @param callback a function that returns the {@link NavigationProgress} by parameters.
849
- */
850
- static onNavigationProgress = callback => {
851
- navigationProgressCallback = callback;
852
- };
853
-
854
- /**
855
- * Callback that notifies when the user reaches the destination POI.
856
- *
857
- * @param callback a function that returns the completed {@link Route} by parameters.
858
- */
859
- static onNavigationDestinationReached = callback => {
860
- navigationDestinationReachedCallback = callback;
861
- };
862
-
863
- /**
864
- * Callback that notifies when the user gets out of the current route.
865
- *
866
- * @param callback the function called when the user gets out of the current route.
867
- */
868
- static onNavigationOutOfRoute = callback => {
869
- navigationOutOfRouteCallback = callback;
870
- };
871
-
872
- /**
873
- * @deprecated
874
- * DEPRECATED: Use instead onNavigationCancellation()
875
- * and onNavigationDestinationReached() to determine why did the navigation end.
876
- *
877
- * Callback that notifies when the user finishes the route.
878
- *
879
- * @param callback the function called when the user finishes the route.
880
- */
881
- static onNavigationFinished = callback => {
882
- navigationFinishedCallback = callback;
883
- };
884
-
885
- /**
886
- * Callback that notifies when the user does cancel the navigation.
887
- *
888
- * @param callback the function called when the user cancels the navigation.
889
- */
890
- static onNavigationCancellation = callback => {
891
- navigationCancellationCallback = callback;
892
- };
893
-
894
- /**
895
- * Callback that notifies when there is an error during navigation.
896
- *
897
- * @param callback the function called when there is an error during navigation.
898
- */
899
- static onNavigationError = callback => {
900
- navigationErrorCallback = callback;
901
- };
902
- }
903
- //# sourceMappingURL=index.js.map