@situm/react-native 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +656 -0
  3. package/ReactNativeSitumPlugin.podspec +22 -0
  4. package/SECURITY-POLICY.md +9 -0
  5. package/android/.gradle/5.6.4/fileChanges/last-build.bin +0 -0
  6. package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
  7. package/android/.gradle/5.6.4/gc.properties +0 -0
  8. package/android/.idea/.name +1 -0
  9. package/android/.idea/codeStyles/Project.xml +116 -0
  10. package/android/.idea/encodings.xml +6 -0
  11. package/android/.idea/misc.xml +31 -0
  12. package/android/.idea/sonarlint/issuestore/index.pb +15 -0
  13. package/android/.project +34 -0
  14. package/android/build.gradle +45 -0
  15. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  16. package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  17. package/android/gradlew +172 -0
  18. package/android/gradlew.bat +84 -0
  19. package/android/src/main/AndroidManifest.xml +6 -0
  20. package/android/src/main/java/com/situm/plugin/PluginHelper.java +989 -0
  21. package/android/src/main/java/com/situm/plugin/SitumMapper.java +1206 -0
  22. package/android/src/main/java/com/situm/plugin/SitumPackage.java +29 -0
  23. package/android/src/main/java/com/situm/plugin/SitumPlugin.java +84 -0
  24. package/android/src/main/java/com/situm/plugin/SitumPluginImpl.java +344 -0
  25. package/android/src/main/java/com/situm/plugin/utils/ReactNativeJson.java +122 -0
  26. package/android/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  27. package/android/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  28. package/android/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  29. package/android/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  30. package/android/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  31. package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  32. package/android/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  33. package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  34. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  35. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  36. package/android/src/main/res/values/strings.xml +3 -0
  37. package/android/src/main/res/values/styles.xml +9 -0
  38. package/ios/Constants.h +14 -0
  39. package/ios/Constants.m +14 -0
  40. package/ios/RNSitumReactNativePlugin.xcodeproj/project.pbxproj +272 -0
  41. package/ios/SitumLocationWrapper.h +112 -0
  42. package/ios/SitumLocationWrapper.m +1132 -0
  43. package/ios/SitumPlugin.h +15 -0
  44. package/ios/SitumPlugin.m +911 -0
  45. package/lib/commonjs/index.js +25 -0
  46. package/lib/commonjs/index.js.map +1 -0
  47. package/lib/commonjs/sdk/index.js +399 -0
  48. package/lib/commonjs/sdk/index.js.map +1 -0
  49. package/lib/commonjs/sdk/nativeInterface.js +20 -0
  50. package/lib/commonjs/sdk/nativeInterface.js.map +1 -0
  51. package/lib/commonjs/sdk/types/index.d.js +6 -0
  52. package/lib/commonjs/sdk/types/index.d.js.map +1 -0
  53. package/lib/commonjs/sdk/utils.js +22 -0
  54. package/lib/commonjs/sdk/utils.js.map +1 -0
  55. package/lib/commonjs/utils/requestPermission.js +73 -0
  56. package/lib/commonjs/utils/requestPermission.js.map +1 -0
  57. package/lib/commonjs/wayfinding/components/MapView.js +220 -0
  58. package/lib/commonjs/wayfinding/components/MapView.js.map +1 -0
  59. package/lib/commonjs/wayfinding/hooks/index.js +401 -0
  60. package/lib/commonjs/wayfinding/hooks/index.js.map +1 -0
  61. package/lib/commonjs/wayfinding/index.js +45 -0
  62. package/lib/commonjs/wayfinding/index.js.map +1 -0
  63. package/lib/commonjs/wayfinding/store/index.js +237 -0
  64. package/lib/commonjs/wayfinding/store/index.js.map +1 -0
  65. package/lib/commonjs/wayfinding/store/utils.js +44 -0
  66. package/lib/commonjs/wayfinding/store/utils.js.map +1 -0
  67. package/lib/commonjs/wayfinding/styles/colors.js +18 -0
  68. package/lib/commonjs/wayfinding/styles/colors.js.map +1 -0
  69. package/lib/commonjs/wayfinding/types/index.d.js +6 -0
  70. package/lib/commonjs/wayfinding/types/index.d.js.map +1 -0
  71. package/lib/commonjs/wayfinding/utils/index.js +11 -0
  72. package/lib/commonjs/wayfinding/utils/index.js.map +1 -0
  73. package/lib/commonjs/wayfinding/utils/mapper.js +106 -0
  74. package/lib/commonjs/wayfinding/utils/mapper.js.map +1 -0
  75. package/lib/module/index.js +6 -0
  76. package/lib/module/index.js.map +1 -0
  77. package/lib/module/sdk/index.js +390 -0
  78. package/lib/module/sdk/index.js.map +1 -0
  79. package/lib/module/sdk/nativeInterface.js +18 -0
  80. package/lib/module/sdk/nativeInterface.js.map +1 -0
  81. package/lib/module/sdk/types/index.d.js +2 -0
  82. package/lib/module/sdk/types/index.d.js.map +1 -0
  83. package/lib/module/sdk/utils.js +15 -0
  84. package/lib/module/sdk/utils.js.map +1 -0
  85. package/lib/module/utils/requestPermission.js +67 -0
  86. package/lib/module/utils/requestPermission.js.map +1 -0
  87. package/lib/module/wayfinding/components/MapView.js +207 -0
  88. package/lib/module/wayfinding/components/MapView.js.map +1 -0
  89. package/lib/module/wayfinding/hooks/index.js +392 -0
  90. package/lib/module/wayfinding/hooks/index.js.map +1 -0
  91. package/lib/module/wayfinding/index.js +12 -0
  92. package/lib/module/wayfinding/index.js.map +1 -0
  93. package/lib/module/wayfinding/store/index.js +202 -0
  94. package/lib/module/wayfinding/store/index.js.map +1 -0
  95. package/lib/module/wayfinding/store/utils.js +34 -0
  96. package/lib/module/wayfinding/store/utils.js.map +1 -0
  97. package/lib/module/wayfinding/styles/colors.js +11 -0
  98. package/lib/module/wayfinding/styles/colors.js.map +1 -0
  99. package/lib/module/wayfinding/types/index.d.js +2 -0
  100. package/lib/module/wayfinding/types/index.d.js.map +1 -0
  101. package/lib/module/wayfinding/utils/index.js +4 -0
  102. package/lib/module/wayfinding/utils/index.js.map +1 -0
  103. package/lib/module/wayfinding/utils/mapper.js +100 -0
  104. package/lib/module/wayfinding/utils/mapper.js.map +1 -0
  105. package/lib/typescript/src/index.d.ts +4 -0
  106. package/lib/typescript/src/index.d.ts.map +1 -0
  107. package/lib/typescript/src/sdk/index.d.ts +269 -0
  108. package/lib/typescript/src/sdk/index.d.ts.map +1 -0
  109. package/lib/typescript/src/sdk/nativeInterface.d.ts +2 -0
  110. package/lib/typescript/src/sdk/nativeInterface.d.ts.map +1 -0
  111. package/lib/typescript/src/sdk/utils.d.ts +7 -0
  112. package/lib/typescript/src/sdk/utils.d.ts.map +1 -0
  113. package/lib/typescript/src/utils/requestPermission.d.ts +3 -0
  114. package/lib/typescript/src/utils/requestPermission.d.ts.map +1 -0
  115. package/lib/typescript/src/wayfinding/components/MapView.d.ts +36 -0
  116. package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -0
  117. package/lib/typescript/src/wayfinding/hooks/index.d.ts +53 -0
  118. package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -0
  119. package/lib/typescript/src/wayfinding/index.d.ts +5 -0
  120. package/lib/typescript/src/wayfinding/index.d.ts.map +1 -0
  121. package/lib/typescript/src/wayfinding/store/index.d.ts +103 -0
  122. package/lib/typescript/src/wayfinding/store/index.d.ts.map +1 -0
  123. package/lib/typescript/src/wayfinding/store/utils.d.ts +9 -0
  124. package/lib/typescript/src/wayfinding/store/utils.d.ts.map +1 -0
  125. package/lib/typescript/src/wayfinding/styles/colors.d.ts +8 -0
  126. package/lib/typescript/src/wayfinding/styles/colors.d.ts.map +1 -0
  127. package/lib/typescript/src/wayfinding/utils/index.d.ts +3 -0
  128. package/lib/typescript/src/wayfinding/utils/index.d.ts.map +1 -0
  129. package/lib/typescript/src/wayfinding/utils/mapper.d.ts +17 -0
  130. package/lib/typescript/src/wayfinding/utils/mapper.d.ts.map +1 -0
  131. package/package.json +130 -0
  132. package/security.txt +4 -0
  133. package/src/index.ts +6 -0
  134. package/src/sdk/index.ts +656 -0
  135. package/src/sdk/nativeInterface.ts +18 -0
  136. package/src/sdk/types/index.d.ts +718 -0
  137. package/src/sdk/utils.ts +16 -0
  138. package/src/utils/requestPermission.ts +94 -0
  139. package/src/wayfinding/components/MapView.tsx +312 -0
  140. package/src/wayfinding/hooks/index.ts +539 -0
  141. package/src/wayfinding/index.tsx +11 -0
  142. package/src/wayfinding/store/index.tsx +254 -0
  143. package/src/wayfinding/store/utils.ts +40 -0
  144. package/src/wayfinding/styles/colors.tsx +6 -0
  145. package/src/wayfinding/types/index.d.ts +56 -0
  146. package/src/wayfinding/utils/index.ts +5 -0
  147. package/src/wayfinding/utils/mapper.ts +129 -0
@@ -0,0 +1,390 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable @typescript-eslint/ban-types */
3
+ import invariant from "invariant";
4
+ import { NativeEventEmitter, NativeModules, Platform } from "react-native";
5
+ import packageJson from "../../package.json";
6
+ import { logError } from "./utils";
7
+ const LINKING_ERROR = `The package 'situm-react-native-plugin' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
8
+ ios: "- You have run 'pod install'\n",
9
+ default: ""
10
+ }) + "- You rebuilt the app after installing the package\n" + "- You are not using Expo managed workflow\n";
11
+ const RNCSitumPlugin = NativeModules.RNCSitumPlugin ? NativeModules.RNCSitumPlugin : new Proxy({}, {
12
+ get() {
13
+ throw new Error(LINKING_ERROR);
14
+ }
15
+ });
16
+ const SitumPluginEventEmitter = new NativeEventEmitter(RNCSitumPlugin);
17
+ let positioningSubscriptions = [];
18
+ let navigationSubscriptions = [];
19
+ let realtimeSubscriptions = [];
20
+ export default {
21
+ /**
22
+ * Initializes SDK.
23
+ *
24
+ * You have to call this function prior any call to other method.
25
+ * This method can be safely called many times as it will only initialise the SDK
26
+ * if it is not already initialised.
27
+ */
28
+ initSitumSDK: function () {
29
+ RNCSitumPlugin.initSitumSDK();
30
+ },
31
+ /**
32
+ * Provides your API key to the Situm SDK.
33
+ *
34
+ * This key is generated for your application in the Dashboard.
35
+ * Old credentials will be removed.
36
+ *
37
+ * @param email user's email.
38
+ * @param apiKey user's apikey.
39
+ * @param onSuccess callback to use when the function returns successfully
40
+ */
41
+ setApiKey: function (email, apiKey, onSuccess) {
42
+ RNCSitumPlugin.setApiKey(email, apiKey, onSuccess);
43
+ },
44
+ /**
45
+ * Provides user's email and password. This credentials will be used to obtain a
46
+ * valid user token to authenticate the server request, when necessary. Token
47
+ * obtaining is not necessary done when this method is executed. Old credentials
48
+ * will be removed.
49
+ *
50
+ * @param email user's email.
51
+ * @param password user's password.
52
+ * @param onSuccess callback to use when the function returns successfully
53
+ */
54
+ setUserPass: function (email, password, onSuccess) {
55
+ RNCSitumPlugin.setUserPass(email, password, onSuccess);
56
+ },
57
+ setDashboardURL: function (url, success) {
58
+ RNCSitumPlugin.setDashboardURL(url, success);
59
+ },
60
+ /**
61
+ * Set to true if you want the SDK to download the configuration from the Situm API
62
+ * and use it by default. Right now it only affects the LocationRequest.
63
+ * Default value is true from SDK version 2.83.5
64
+ *
65
+ * @param useRemoteConfig boolean
66
+ * @param success function called on sucess
67
+ */
68
+ setUseRemoteConfig(useRemoteConfig, onSuccess) {
69
+ RNCSitumPlugin.setUseRemoteConfig(useRemoteConfig, onSuccess);
70
+ },
71
+ /**
72
+ * Sets the maximum age of a cached response. If the cache response's age exceeds
73
+ * maxAge, it will not be used and a network request will be made.
74
+ *
75
+ * @param cacheAge a non-negative integer
76
+ * @param success function called on success
77
+ */
78
+ setCacheMaxAge: function (cacheAge, success) {
79
+ RNCSitumPlugin.setCacheMaxAge(cacheAge, success);
80
+ },
81
+ /**
82
+ * Invalidate all the resources in the cache
83
+ */
84
+ invalidateCache: function () {
85
+ RNCSitumPlugin.invalidateCache();
86
+ },
87
+ /**
88
+ * Gets the list of versions for the current plugin and environment
89
+ *
90
+ * @param callback callback to use on success
91
+ */
92
+ sdkVersions: function (callback) {
93
+ const versions = {
94
+ react_native: packageJson.version
95
+ };
96
+ if (Platform.OS === "ios") {
97
+ versions.ios = packageJson.sdkVersions.ios;
98
+ } else {
99
+ versions.android = packageJson.sdkVersions.android;
100
+ }
101
+ callback(versions);
102
+ },
103
+ /**
104
+ * Returns the device identifier that has generated the location
105
+ *
106
+ * @param callback function called on sucess, returns the id of the current device
107
+ */
108
+ getDeviceId: function (callback) {
109
+ RNCSitumPlugin.getDeviceId(callback);
110
+ },
111
+ /**
112
+ * Request authorization for the provided authentication
113
+ * and stores it internally for subsequent requests
114
+ */
115
+ requestAuthorization: function () {
116
+ RNCSitumPlugin.requestAuthorization();
117
+ },
118
+ /**
119
+ * Download all the buildings for the current user
120
+ *
121
+ * @param success function called on sucess, returns a list of Building objects
122
+ * @param error function called on failure, returns an error string
123
+ */
124
+ fetchBuildings: function (success, error) {
125
+ invariant(typeof success === "function", "Must provide a valid success callback.");
126
+ RNCSitumPlugin.fetchBuildings(success, error || logError);
127
+ },
128
+ /**
129
+ * Download all the building data for the selected building. This info includes
130
+ * floors, indoor and outdoor POIs, events and paths. Also it download floor
131
+ * maps and POI category icons to local storage.
132
+ *
133
+ * @param building
134
+ * @param success function called on sucess, returns a list of Building objects
135
+ * @param error function called on failure, returns an error string
136
+ */
137
+ fetchBuildingInfo: function (building, success, error) {
138
+ invariant(typeof success === "function", "Must provide a valid success callback.");
139
+ RNCSitumPlugin.fetchBuildingInfo(building, success, error || logError);
140
+ },
141
+ fetchTilesFromBuilding: function (building, success, error) {
142
+ invariant(typeof success === "function", "Must provide a valid success callback.");
143
+ RNCSitumPlugin.fetchTilesFromBuilding(building, success, error || logError);
144
+ },
145
+ /**
146
+ * Download all the floors of a building
147
+ *
148
+ * @param building
149
+ * @param success function called on sucess, returns a list of Floor objects
150
+ * @param error function called on failure, returns an error string
151
+ */
152
+ fetchFloorsFromBuilding: function (building, success, error) {
153
+ invariant(typeof success === "function", "Must provide a valid success callback.");
154
+ RNCSitumPlugin.fetchFloorsFromBuilding(building, success, error || logError);
155
+ },
156
+ /**
157
+ * Download the map image of a floor
158
+ *
159
+ * @param floor the floor object. Not null.
160
+ * @param success function called on sucess, returns a list of Map url objects
161
+ * @param error function called on failure, returns an error string
162
+ */
163
+ fetchMapFromFloor: function (floor, success, error) {
164
+ invariant(typeof success === "function", "Must provide a valid success callback.");
165
+ RNCSitumPlugin.fetchMapFromFloor(floor, success, error || logError);
166
+ },
167
+ /**
168
+ * Get the geofences of a building
169
+ *
170
+ * @param building
171
+ * @param success function called on sucess, returns a list of Building objects
172
+ * @param error function called on failure, returns an error string
173
+ */
174
+ fetchGeofencesFromBuilding: function (building, success, error) {
175
+ invariant(typeof success === "function", "Must provide a valid success callback.");
176
+ RNCSitumPlugin.fetchGeofencesFromBuilding(building, success, error || logError);
177
+ },
178
+ /**
179
+ * Get all POI categories, download and cache their icons asynchronously.
180
+ *
181
+ * @param success function called on sucess, returns a list of POI categories
182
+ * @param error function called on failure, returns an error string
183
+ */
184
+ fetchPoiCategories: function (success, error) {
185
+ invariant(typeof success === "function", "Must provide a valid success callback.");
186
+ RNCSitumPlugin.fetchPoiCategories(success, error || logError);
187
+ },
188
+ /**
189
+ * Get the normal category icon for a category
190
+ *
191
+ * @param category the category. Not null.
192
+ * @param success function called on sucess, returns the icon in normal state.
193
+ * @param error function called on failure, returns an error string
194
+ */
195
+ fetchPoiCategoryIconNormal: function (category, success, error) {
196
+ invariant(typeof success === "function", "Must provide a valid success callback.");
197
+ RNCSitumPlugin.fetchPoiCategoryIconNormal(category, success, error || logError);
198
+ },
199
+ /**
200
+ * Get the selected category icon for a category
201
+ *
202
+ * @param category the category. Not null.
203
+ * @param success function called on sucess, returns the icon in selected state.
204
+ * @param error function called on failure, returns an error string
205
+ */
206
+ fetchPoiCategoryIconSelected: function (category, success, error) {
207
+ invariant(typeof success === "function", "Must provide a valid success callback.");
208
+ RNCSitumPlugin.fetchPoiCategoryIconSelected(category, success, error || logError);
209
+ },
210
+ /**
211
+ * Download the indoor POIs of a building
212
+ *
213
+ * @param building
214
+ * @param success function called on sucess, returns a list of POI objects
215
+ * @param error function called on failure, returns an error string
216
+ */
217
+ fetchIndoorPOIsFromBuilding: function (building, success, error) {
218
+ invariant(typeof success === "function", "Must provide a valid success callback.");
219
+ RNCSitumPlugin.fetchIndoorPOIsFromBuilding(building, success, error || logError);
220
+ },
221
+ /**
222
+ * Download the outdoor POIs of a building
223
+ *
224
+ * @param building
225
+ * @param success function called on sucess, returns a list of POI objects
226
+ * @param error function called on failure, returns an error string
227
+ */
228
+ fetchOutdoorPOIsFromBuilding: function (building, success, error) {
229
+ invariant(typeof success === "function", "Must provide a valid success callback.");
230
+ RNCSitumPlugin.fetchOutdoorPOIsFromBuilding(building, success, error || logError);
231
+ },
232
+ /**
233
+ * Download the events of a building
234
+ *
235
+ * @param building
236
+ * @param success Callback to asynchronously receive the events of a building. Not null.
237
+ * @param error function called on failure, returns an error string
238
+ */
239
+ fetchEventsFromBuilding: function (building, success, error) {
240
+ invariant(typeof success === "function", "Must provide a valid success callback.");
241
+ RNCSitumPlugin.fetchEventsFromBuilding(building, success, error || logError);
242
+ },
243
+ /**
244
+ * Starts positioning with the configuration specified by the LocationRequest;
245
+ * computed geolocations, status codes and errors will be received through the LocationListener callbacks.
246
+ * You may call this method more than once, with the following effect:
247
+ *
248
+ * - If you provide a new LocationRequest instance, positioning will be re-started
249
+ * with the new positioning options specified by this new instance.
250
+ * - If you provide a new LocationListener, the former LocationListener will be
251
+ * replaced, therefore geolocations will be communicated to the new one.
252
+ * - If neither LocationRequest nor LocationListener change, nothing will happen.
253
+ * You may stop positioning at any time by calling the LocationManager.removeUpdates() method.
254
+ *
255
+ * @param location callback to use when location is udpated
256
+ * @param status callback to use when the positioning status changes
257
+ * @param error callback to use when error is raised
258
+ * @param locationOptions hashmap with options
259
+ *
260
+ * @returns the id of the subscription
261
+ */
262
+ startPositioning: function (location, status, error, options) {
263
+ this.requestAuthorization();
264
+ return this.startPositioningUpdates(location, status, error || logError, options || {});
265
+ },
266
+ startPositioningUpdates: function (location, status, error, options) {
267
+ // Remove old positioning subscriptions:
268
+ positioningSubscriptions.forEach(subscription => subscription === null || subscription === void 0 ? void 0 : subscription.remove());
269
+ positioningSubscriptions = [];
270
+ positioningSubscriptions.push(SitumPluginEventEmitter.addListener("locationChanged", location), SitumPluginEventEmitter.addListener("statusChanged", status), error ? SitumPluginEventEmitter.addListener("locationError", error || logError) : null);
271
+ // Call native:
272
+ RNCSitumPlugin.startPositioning(options || {});
273
+ },
274
+ /**
275
+ * Stops positioning, removing all location updates
276
+ *
277
+ * @param callback the callback to use when the function successfully ends
278
+ * @returns
279
+ */
280
+ stopPositioning: function (callback) {
281
+ RNCSitumPlugin.stopPositioning(callback || logError);
282
+ },
283
+ /**
284
+ * Calculates a route between two points. The result is provided
285
+ * asynchronously using the callback.
286
+ *
287
+ * @param directionParams
288
+ * @param success function called on sucess, returns a Route object
289
+ * @param error function called on failure, returns an error string
290
+ */
291
+ requestDirections: function (directionParams, success, error) {
292
+ invariant(typeof success === "function", "Must provide a valid success callback.");
293
+ RNCSitumPlugin.requestDirections(directionParams, success, error || logError);
294
+ },
295
+ /**
296
+ * Set the navigation params, and the listener that receives the updated
297
+ * navigation progress.
298
+ *
299
+ * Can only exist one navigation with one listener at a time. If this method was
300
+ * previously invoked, but removeUpdates() wasn't, removeUpdates() is called internally.
301
+ *
302
+ * @param navigationUpdates
303
+ * @param error function called on failure, returns an error string
304
+ * @param options
305
+ */
306
+ requestNavigationUpdates: function (navigationUpdates, error, options) {
307
+ RNCSitumPlugin.requestNavigationUpdates(options || {});
308
+ navigationSubscriptions.push(SitumPluginEventEmitter.addListener("navigationUpdated", navigationUpdates));
309
+ navigationSubscriptions.push(error ? SitumPluginEventEmitter.addListener("navigationError", error || logError) : null);
310
+ },
311
+ /**
312
+ * Informs NavigationManager object the change of the user's location
313
+ *
314
+ * @param location new Location of the user. If null, nothing is done
315
+ * @param success callback to use when the navigation updates
316
+ * @param error callback to use when an error on navigation udpates raises
317
+ */
318
+ updateNavigationWithLocation: function (location, success, error) {
319
+ if (navigationSubscriptions.length === 0) {
320
+ error("No active navigation!!");
321
+ return;
322
+ }
323
+ RNCSitumPlugin.updateNavigationWithLocation(location, success, error || logError);
324
+ },
325
+ /**
326
+ * Removes all location updates. This removes the internal state of the manager,
327
+ * including the listener provided in requestNavigationUpdates(NavigationRequest,
328
+ * NavigationListener), so it won't receive more progress updates.
329
+ *
330
+ * @param callback
331
+ */
332
+ removeNavigationUpdates: function (callback) {
333
+ for (let i = 0; i < navigationSubscriptions.length; i++) {
334
+ navigationSubscriptions[i].remove();
335
+ }
336
+ navigationSubscriptions = [];
337
+ RNCSitumPlugin.removeNavigationUpdates(callback || logError);
338
+ },
339
+ requestRealTimeUpdates: function (navigationUpdates, error, options) {
340
+ RNCSitumPlugin.requestRealTimeUpdates(options || {});
341
+ realtimeSubscriptions.push([SitumPluginEventEmitter.addListener("realtimeUpdated", navigationUpdates), error ? SitumPluginEventEmitter.addListener("realtimeError", error || logError) : null]);
342
+ },
343
+ /**
344
+ * Requests a real time devices positions
345
+ *
346
+ * @param realtimeUpdates callback to use when new device positions are updated
347
+ * @param error callback to use when an error on navigation udpates raises
348
+ * @param options Represents the configuration for getting realtime devices positions in
349
+ */
350
+ removeRealTimeUpdates: function (_callback) {
351
+ realtimeSubscriptions = [];
352
+ RNCSitumPlugin.removeRealTimeUpdates();
353
+ },
354
+ checkIfPointInsideGeofence: function (request, callback) {
355
+ invariant(typeof callback === "function", "Must provide a valid success callback.");
356
+ RNCSitumPlugin.checkIfPointInsideGeofence(request, callback);
357
+ },
358
+ /**
359
+ * Callback that notifies when the user enters a geofence.
360
+ *
361
+ * In order to use correctly these callbacks you must know the following:
362
+ * - Positioning geofences (with trainer_metadata custom field) won't be notified.
363
+ * - These callbacks only work with indoor locations. Any outdoor location will
364
+ * produce a call to onExitedGeofences with the last positioned geofences as argument.
365
+ *
366
+ * @param callback the function called when the user enters a geofence
367
+ */
368
+ onEnterGeofences: function (callback) {
369
+ RNCSitumPlugin.onEnterGeofences();
370
+ // Adopts SDK behavior (setter):
371
+ SitumPluginEventEmitter.removeAllListeners("onEnterGeofences");
372
+ SitumPluginEventEmitter.addListener("onEnterGeofences", callback);
373
+ },
374
+ /**
375
+ * Callback that notifies when the user exits a geofence.
376
+ *
377
+ * In order to use correctly these callbacks you must know the following:
378
+ * - Positioning geofences (with trainer_metadata custom field) won't be notified.
379
+ * - These callbacks only work with indoor locations. Any outdoor location will
380
+ * produce a call to onExitedGeofences with the last positioned geofences as argument.
381
+ *
382
+ * @param callback the function called when the user exits a geofence
383
+ */
384
+ onExitGeofences: function (callback) {
385
+ RNCSitumPlugin.onExitGeofences();
386
+ SitumPluginEventEmitter.removeAllListeners("onExitGeofences");
387
+ SitumPluginEventEmitter.addListener("onExitGeofences", callback);
388
+ }
389
+ };
390
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["invariant","NativeEventEmitter","NativeModules","Platform","packageJson","logError","LINKING_ERROR","select","ios","default","RNCSitumPlugin","Proxy","get","Error","SitumPluginEventEmitter","positioningSubscriptions","navigationSubscriptions","realtimeSubscriptions","initSitumSDK","setApiKey","email","apiKey","onSuccess","setUserPass","password","setDashboardURL","url","success","setUseRemoteConfig","useRemoteConfig","setCacheMaxAge","cacheAge","invalidateCache","sdkVersions","callback","versions","react_native","version","OS","android","getDeviceId","requestAuthorization","fetchBuildings","error","fetchBuildingInfo","building","fetchTilesFromBuilding","fetchFloorsFromBuilding","fetchMapFromFloor","floor","fetchGeofencesFromBuilding","fetchPoiCategories","fetchPoiCategoryIconNormal","category","fetchPoiCategoryIconSelected","fetchIndoorPOIsFromBuilding","fetchOutdoorPOIsFromBuilding","fetchEventsFromBuilding","startPositioning","location","status","options","startPositioningUpdates","forEach","subscription","remove","push","addListener","stopPositioning","requestDirections","directionParams","requestNavigationUpdates","navigationUpdates","updateNavigationWithLocation","length","removeNavigationUpdates","i","requestRealTimeUpdates","removeRealTimeUpdates","_callback","checkIfPointInsideGeofence","request","onEnterGeofences","removeAllListeners","onExitGeofences"],"sourceRoot":"../../../src","sources":["sdk/index.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,SAAS,MAAM,WAAW;AACjC,SAASC,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,OAAOC,WAAW,MAAM,oBAAoB;AAQ5C,SAASC,QAAQ,QAAQ,SAAS;AAElC,MAAMC,aAAa,GAChB,oFAAmF,GACpFH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAE/C,MAAMC,cAAc,GAAGR,aAAa,CAACQ,cAAc,GAC/CR,aAAa,CAACQ,cAAc,GAC5B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACP,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,MAAMQ,uBAAuB,GAAG,IAAIb,kBAAkB,CAACS,cAAc,CAAC;AAEtE,IAAIK,wBAAwB,GAAG,EAAE;AACjC,IAAIC,uBAAuB,GAAG,EAAE;AAChC,IAAIC,qBAAqB,GAAG,EAAE;AAE9B,eAAe;EACb;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,YAAY,EAAE,SAAAA,CAAA,EAAkB;IAC9BR,cAAc,CAACQ,YAAY,CAAC,CAAC;EAC/B,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,SAAS,EAAE,SAAAA,CACTC,KAAa,EACbC,MAAc,EACdC,SAAoB,EACd;IACNZ,cAAc,CAACS,SAAS,CAACC,KAAK,EAAEC,MAAM,EAAEC,SAAS,CAAC;EACpD,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAW,EAAE,SAAAA,CACXH,KAAa,EACbI,QAAgB,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ACjC,eAAe,EACfxB,KAAK,IAAItC,QACX,CAAC,GACD,IAAI,CACT,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACEyE,qBAAqB,EAAE,SAAAA,CAAUC,SAAoB,EAAE;IACrD9D,qBAAqB,GAAG,EAAE;IAC1BP,cAAc,CAACoE,qBAAqB,CAAC,CAAC;EACxC,CAAC;EAEDE,0BAA0B,EAAE,SAAAA,CAAUC,OAAY,EAAE/C,QAAmB,EAAE;IACvElC,SAAS,CACP,OAAOkC,QAAQ,KAAK,UAAU,EAC9B,wCACF,CAAC;IAEDxB,cAAc,CAACsE,0BAA0B,CAACC,OAAO,EAAE/C,QAAQ,CAAC;EAC9D,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEgD,gBAAgB,EAAE,SAAAA,CAAUhD,QAA8B,EAAE;IAC1DxB,cAAc,CAACwE,gBAAgB,CAAC,CAAC;IACjC;IACApE,uBAAuB,CAACqE,kBAAkB,CAAC,kBAAkB,CAAC;IAC9DrE,uBAAuB,CAACqD,WAAW,CAAC,kBAAkB,EAAEjC,QAAQ,CAAC;EACnE,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEkD,eAAe,EAAE,SAAAA,CAAUlD,QAA8B,EAAE;IACzDxB,cAAc,CAAC0E,eAAe,CAAC,CAAC;IAChCtE,uBAAuB,CAACqE,kBAAkB,CAAC,iBAAiB,CAAC;IAC7DrE,uBAAuB,CAACqD,WAAW,CAAC,iBAAiB,EAAEjC,QAAQ,CAAC;EAClE;AACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { NativeEventEmitter, NativeModules } from "react-native";
2
+ const {
3
+ RNCSitumPlugin
4
+ } = NativeModules;
5
+ if (!RNCSitumPlugin) {
6
+ throw new Error("react-native-situm-plugin: NativeModule is null");
7
+ }
8
+ let nativeEventEmitter = null;
9
+ module.exports = {
10
+ RNCSitumPlugin,
11
+ get SitumPluginEventEmitter() {
12
+ if (!nativeEventEmitter) {
13
+ nativeEventEmitter = new NativeEventEmitter(RNCSitumPlugin);
14
+ }
15
+ return nativeEventEmitter;
16
+ }
17
+ };
18
+ //# sourceMappingURL=nativeInterface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","RNCSitumPlugin","Error","nativeEventEmitter","module","exports","SitumPluginEventEmitter"],"sourceRoot":"../../../src","sources":["sdk/nativeInterface.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAEhE,MAAM;EAAEC;AAAe,CAAC,GAAGD,aAAa;AAExC,IAAI,CAACC,cAAc,EAAE;EACnB,MAAM,IAAIC,KAAK,CAAC,iDAAiD,CAAC;AACpE;AAEA,IAAIC,kBAAkB,GAAG,IAAI;AAC7BC,MAAM,CAACC,OAAO,GAAG;EACfJ,cAAc;EACd,IAAIK,uBAAuBA,CAAA,EAAG;IAC5B,IAAI,CAACH,kBAAkB,EAAE;MACvBA,kBAAkB,GAAG,IAAIJ,kBAAkB,CAACE,cAAc,CAAC;IAC7D;IACA,OAAOE,kBAAkB;EAC3B;AACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["sdk/types/index.d.ts"],"mappings":""}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Small utility that can be used as an error handler. You cannot just pass
3
+ * `console.error` as a failure callback - it's not properly bound. If passes an
4
+ * `Error` object, it will print the message and stack.
5
+ */
6
+ export const logError = __DEV__ ? function (response) {
7
+ if (response instanceof String) {
8
+ console.log(response);
9
+ } else {
10
+ console.log(JSON.stringify(response));
11
+ }
12
+ } : function (_response) {
13
+ // do nothing
14
+ };
15
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["logError","__DEV__","response","String","console","log","JSON","stringify","_response"],"sourceRoot":"../../../src","sources":["sdk/utils.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAGC,OAAO,GAC3B,UAAUC,QAAiB,EAAE;EAC3B,IAAIA,QAAQ,YAAYC,MAAM,EAAE;IAC9BC,OAAO,CAACC,GAAG,CAACH,QAAQ,CAAC;EACvB,CAAC,MAAM;IACLE,OAAO,CAACC,GAAG,CAACC,IAAI,CAACC,SAAS,CAACL,QAAQ,CAAC,CAAC;EACvC;AACF,CAAC,GACD,UAAUM,SAAS,EAAE;EACnB;AAAA,CACD"}
@@ -0,0 +1,67 @@
1
+ import { Platform } from "react-native";
2
+ import { PERMISSIONS, request, requestMultiple, RESULTS } from "react-native-permissions";
3
+
4
+ // TODO: can requestMultiple be used ?
5
+ const checkIOSPermissions = async () => {
6
+ let granted = await request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
7
+ if (granted === RESULTS.GRANTED) {
8
+ console.info("LOCATION_WHEN_IN_USE permission granted");
9
+
10
+ //@ts-ignore
11
+ if (parseInt(Platform.Version, 10) > 12) {
12
+ granted = await request(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL);
13
+ if (granted === RESULTS.GRANTED) {
14
+ console.info("BLUETOOTH_PERIPHERAL permission granted");
15
+ return true;
16
+ } else {
17
+ throw "BLUETOOTH_PERIPHERAL permission not granted";
18
+ }
19
+ } else {
20
+ console.warn("BLUETOOTH_PERIPHERAL permissions not required");
21
+ return true;
22
+ }
23
+ } else {
24
+ throw "ACCESS_FINE_LOCATION denied";
25
+ }
26
+ };
27
+ const checkAndroidPermissions = async () => {
28
+ let granted;
29
+ //@ts-ignore
30
+ if (Platform.Version > 30) {
31
+ console.log("ANDROID VERSION > 30");
32
+ granted = await requestMultiple([PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION, PERMISSIONS.ANDROID.BLUETOOTH_CONNECT, PERMISSIONS.ANDROID.BLUETOOTH_SCAN]);
33
+ if (granted["android.permission.ACCESS_FINE_LOCATION"] === RESULTS.GRANTED && granted["android.permission.BLUETOOTH_CONNECT"] === RESULTS.GRANTED && granted["android.permission.BLUETOOTH_SCAN"] === RESULTS.GRANTED) {
34
+ console.info("ACCESS_FINE_LOCATION, BLUETOOTH_CONNECT and ACCESS_FINE_LOCATION permissions granted");
35
+ return true;
36
+ }
37
+ throw "ACCESS_FINE_LOCATION, BLUETOOTH_CONNECT and ACCESS_FINE_LOCATION permissions not granted";
38
+ } else {
39
+ console.info("ANDROID VERSION < 30");
40
+ granted = await request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION);
41
+ if (granted === RESULTS.GRANTED) {
42
+ console.info("ACCESS_FINE_LOCATION granted");
43
+ return true;
44
+ } else {
45
+ throw "ACCESS_FINE_LOCATION permission not granted";
46
+ }
47
+ }
48
+ };
49
+ const requestPermission = () =>
50
+ // eslint-disable-next-line no-async-promise-executor
51
+ new Promise(async (resolve, reject) => {
52
+ console.log("Retrieving permissions for platform " + Platform.OS);
53
+ if (Platform.OS === "ios") {
54
+ await checkIOSPermissions().then(() => resolve()).catch(e => {
55
+ console.warn(e);
56
+ reject(e);
57
+ });
58
+ } else if (Platform.OS === "android") {
59
+ await checkAndroidPermissions().then(() => resolve()).catch(e => {
60
+ console.warn(e);
61
+ reject(e);
62
+ });
63
+ }
64
+ reject(`Platform ${Platform.OS} not supported`);
65
+ });
66
+ export default requestPermission;
67
+ //# sourceMappingURL=requestPermission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","PERMISSIONS","request","requestMultiple","RESULTS","checkIOSPermissions","granted","IOS","LOCATION_WHEN_IN_USE","GRANTED","console","info","parseInt","Version","BLUETOOTH_PERIPHERAL","warn","checkAndroidPermissions","log","ANDROID","ACCESS_FINE_LOCATION","BLUETOOTH_CONNECT","BLUETOOTH_SCAN","requestPermission","Promise","resolve","reject","OS","then","catch","e"],"sourceRoot":"../../../src","sources":["utils/requestPermission.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,c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