@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,16 @@
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__
7
+ ? function (response: unknown) {
8
+ if (response instanceof String) {
9
+ console.log(response);
10
+ } else {
11
+ console.log(JSON.stringify(response));
12
+ }
13
+ }
14
+ : function (_response) {
15
+ // do nothing
16
+ };
@@ -0,0 +1,94 @@
1
+ import { Platform } from "react-native";
2
+ import {
3
+ PERMISSIONS,
4
+ request,
5
+ requestMultiple,
6
+ RESULTS,
7
+ } from "react-native-permissions";
8
+
9
+ // TODO: can requestMultiple be used ?
10
+ const checkIOSPermissions = async () => {
11
+ let granted = await request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
12
+
13
+ if (granted === RESULTS.GRANTED) {
14
+ console.info("LOCATION_WHEN_IN_USE permission granted");
15
+
16
+ //@ts-ignore
17
+ if (parseInt(Platform.Version, 10) > 12) {
18
+ granted = await request(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL);
19
+
20
+ if (granted === RESULTS.GRANTED) {
21
+ console.info("BLUETOOTH_PERIPHERAL permission granted");
22
+ return true;
23
+ } else {
24
+ throw "BLUETOOTH_PERIPHERAL permission not granted";
25
+ }
26
+ } else {
27
+ console.warn("BLUETOOTH_PERIPHERAL permissions not required");
28
+ return true;
29
+ }
30
+ } else {
31
+ throw "ACCESS_FINE_LOCATION denied";
32
+ }
33
+ };
34
+
35
+ const checkAndroidPermissions = async () => {
36
+ let granted;
37
+ //@ts-ignore
38
+ if (Platform.Version > 30) {
39
+ console.log("ANDROID VERSION > 30");
40
+ granted = await requestMultiple([
41
+ PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
42
+ PERMISSIONS.ANDROID.BLUETOOTH_CONNECT,
43
+ PERMISSIONS.ANDROID.BLUETOOTH_SCAN,
44
+ ]);
45
+
46
+ if (
47
+ granted["android.permission.ACCESS_FINE_LOCATION"] === RESULTS.GRANTED &&
48
+ granted["android.permission.BLUETOOTH_CONNECT"] === RESULTS.GRANTED &&
49
+ granted["android.permission.BLUETOOTH_SCAN"] === RESULTS.GRANTED
50
+ ) {
51
+ console.info(
52
+ "ACCESS_FINE_LOCATION, BLUETOOTH_CONNECT and ACCESS_FINE_LOCATION permissions granted"
53
+ );
54
+ return true;
55
+ }
56
+
57
+ throw "ACCESS_FINE_LOCATION, BLUETOOTH_CONNECT and ACCESS_FINE_LOCATION permissions not granted";
58
+ } else {
59
+ console.info("ANDROID VERSION < 30");
60
+ granted = await request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION);
61
+
62
+ if (granted === RESULTS.GRANTED) {
63
+ console.info("ACCESS_FINE_LOCATION granted");
64
+ return true;
65
+ } else {
66
+ throw "ACCESS_FINE_LOCATION permission not granted";
67
+ }
68
+ }
69
+ };
70
+
71
+ const requestPermission = () =>
72
+ // eslint-disable-next-line no-async-promise-executor
73
+ new Promise<void>(async (resolve, reject) => {
74
+ console.log("Retrieving permissions for platform " + Platform.OS);
75
+ if (Platform.OS === "ios") {
76
+ await checkIOSPermissions()
77
+ .then(() => resolve())
78
+ .catch((e: string) => {
79
+ console.warn(e);
80
+ reject(e);
81
+ });
82
+ } else if (Platform.OS === "android") {
83
+ await checkAndroidPermissions()
84
+ .then(() => resolve())
85
+ .catch((e: string) => {
86
+ console.warn(e);
87
+ reject(e);
88
+ });
89
+ }
90
+
91
+ reject(`Platform ${Platform.OS} not supported`);
92
+ });
93
+
94
+ export default requestPermission;
@@ -0,0 +1,312 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable @typescript-eslint/no-empty-function */
3
+ import React, { useEffect, useRef, useState } from "react";
4
+ import { Platform, StyleSheet } from "react-native";
5
+ import WebView from "react-native-webview";
6
+ import {
7
+ WebViewErrorEvent,
8
+ WebViewMessageEvent,
9
+ } from "react-native-webview/lib/WebViewTypes";
10
+
11
+ //This icon should either be inside plugin or not be used rat all
12
+ import useSitum from "../hooks";
13
+ import {
14
+ NavigationStatus,
15
+ NavigationUpdateType,
16
+ setWebViewRef,
17
+ } from "../store";
18
+ import { useDispatch } from "../store/utils";
19
+ import {
20
+ MapViewError,
21
+ OnFloorChangedResult,
22
+ OnNavigationResult,
23
+ OnPoiDeselectedResult,
24
+ OnPoiSelectedResult,
25
+ WayfindingResult,
26
+ } from "../types/index.d";
27
+ import { sendMessageToViewer } from "../utils";
28
+ import Mapper from "../utils/mapper";
29
+
30
+ const SITUM_BASE_DOMAIN = "https://map-viewer.situm.com";
31
+
32
+ // Define class that handles errors
33
+ export enum ErrorName {
34
+ ERR_INTERNET_DISCONNECTED = "ERR_INTERNET_DISCONNECTED",
35
+ ERR_INTERNAL_SERVER_ERROR = "ERR_INTERNAL_SERVER_ERROR",
36
+ }
37
+
38
+ const NETWORK_ERROR_CODE = {
39
+ android: -2,
40
+ ios: -1009,
41
+ // These platforms are unhandled
42
+ windows: 0,
43
+ macos: 0,
44
+ web: 0,
45
+ };
46
+
47
+ export interface MapViewProps {
48
+ domain?: string;
49
+ user?: string;
50
+ apikey?: string;
51
+ configuration?: {
52
+ buildingIdentifier?: string;
53
+ enablePoiClustering?: boolean;
54
+ showPoiNames?: boolean;
55
+ useRemoteConfig?: boolean;
56
+ minZoom?: number;
57
+ maxZoom?: number;
58
+ initialZoom?: number;
59
+ useDashboardTheme?: boolean;
60
+ };
61
+ googleApikey?: string;
62
+ onLoadError?: (event: MapViewError) => void;
63
+ onLoad?: (event: WayfindingResult) => void;
64
+ onFloorChanged?: (event: OnFloorChangedResult) => void;
65
+ onPoiSelected?: (event: OnPoiSelectedResult) => void;
66
+ onPoiDeselected?: (event: OnPoiDeselectedResult) => void;
67
+ onNavigationRequested?: (event: OnNavigationResult) => void;
68
+ onNavigationStarted?: (event: OnNavigationResult) => void;
69
+ onNavigationError?: (event: OnNavigationResult) => void;
70
+ onNavigationFinished?: (event: OnNavigationResult) => void;
71
+ style?: any;
72
+ iOSMapViewIndex?: string;
73
+ }
74
+
75
+ const viewerStyles = StyleSheet.create({
76
+ webview: {
77
+ minHeight: "100%",
78
+ minWidth: "100%",
79
+ },
80
+ });
81
+
82
+ const MapView: React.FC<MapViewProps> = ({
83
+ domain,
84
+ // user,
85
+ // apikey,
86
+ configuration,
87
+ onLoad = () => {},
88
+ onLoadError = () => {},
89
+ onFloorChanged = () => {},
90
+ onPoiSelected = () => {},
91
+ onPoiDeselected = () => {},
92
+ onNavigationRequested = () => {},
93
+ onNavigationStarted = () => {},
94
+ onNavigationError = () => {},
95
+ onNavigationFinished = () => {},
96
+ style,
97
+ //iOSMapViewIndex,
98
+ }) => {
99
+ const dispatch = useDispatch();
100
+ const webViewRef = useRef();
101
+ // Local states
102
+ const [mapLoaded, setMapLoaded] = useState<boolean>(false);
103
+
104
+ const {
105
+ user: fullUser,
106
+ location,
107
+ directions,
108
+ navigation,
109
+ currentBuilding,
110
+ initializeBuildingById,
111
+ calculateRoute,
112
+ startNavigation,
113
+ stopNavigation,
114
+ error,
115
+ } = useSitum();
116
+
117
+ const sendFollowUser = () => {
118
+ if (
119
+ webViewRef.current &&
120
+ mapLoaded &&
121
+ location?.position?.buildingIdentifier ===
122
+ configuration?.buildingIdentifier
123
+ ) {
124
+ sendMessageToViewer(webViewRef.current, Mapper.followUser(true));
125
+ }
126
+ };
127
+
128
+ useEffect(() => {
129
+ configuration.buildingIdentifier &&
130
+ initializeBuildingById(configuration.buildingIdentifier);
131
+ // eslint-disable-next-line react-hooks/exhaustive-deps
132
+ }, [configuration.buildingIdentifier]);
133
+
134
+ useEffect(() => {
135
+ if (error) {
136
+ console.error(
137
+ "Error code:",
138
+ error.code ? error.code : " no code provided"
139
+ );
140
+ console.error("Error detected:", error.message);
141
+ }
142
+ }, [error]);
143
+
144
+ // Updated SDK location
145
+ useEffect(() => {
146
+ if (!webViewRef.current || !location) return;
147
+ //console.debug('location', location);
148
+
149
+ sendMessageToViewer(webViewRef.current, Mapper.location(location));
150
+ }, [location]);
151
+
152
+ // Updated SDK navigation
153
+ useEffect(() => {
154
+ if (!webViewRef.current || !navigation) return;
155
+
156
+ sendMessageToViewer(webViewRef.current, Mapper.navigation(navigation));
157
+
158
+ if (navigation.status === NavigationStatus.START) {
159
+ onNavigationStarted({
160
+ navigation: Mapper.routeToResult(navigation),
161
+ } as OnNavigationResult);
162
+ }
163
+ if (navigation?.type === NavigationUpdateType.destinationReached) {
164
+ onNavigationFinished({
165
+ navigation: Mapper.navigationToResult(navigation),
166
+ } as OnNavigationResult);
167
+ }
168
+ // eslint-disable-next-line react-hooks/exhaustive-deps
169
+ }, [navigation]);
170
+
171
+ // Updated SDK route
172
+ useEffect(() => {
173
+ if (!webViewRef.current || !directions) return;
174
+
175
+ sendMessageToViewer(webViewRef.current, Mapper.route(directions));
176
+ }, [directions]);
177
+
178
+ useEffect(() => {
179
+ if (webViewRef.current && mapLoaded) {
180
+ sendMessageToViewer(
181
+ webViewRef.current,
182
+ Mapper.initialConfiguration(
183
+ style,
184
+ configuration.enablePoiClustering,
185
+ configuration.showPoiNames,
186
+ configuration.minZoom,
187
+ configuration.maxZoom,
188
+ configuration.initialZoom,
189
+ configuration.useDashboardTheme
190
+ )
191
+ );
192
+ }
193
+ }, [
194
+ webViewRef,
195
+ mapLoaded,
196
+ style,
197
+ configuration.enablePoiClustering,
198
+ configuration.showPoiNames,
199
+ configuration.minZoom,
200
+ configuration.maxZoom,
201
+ configuration.initialZoom,
202
+ configuration.useDashboardTheme,
203
+ ]);
204
+
205
+ const handleRequestFromViewer = (event: WebViewMessageEvent) => {
206
+ const eventParsed = JSON.parse(event.nativeEvent.data);
207
+ switch (eventParsed.type) {
208
+ case "app.map_is_ready":
209
+ onLoad({
210
+ status: "SUCCESS",
211
+ message: "Map is ready!",
212
+ } as WayfindingResult);
213
+ sendFollowUser();
214
+ break;
215
+ case "directions.requested":
216
+ calculateRoute({
217
+ originId: JSON.parse(event.nativeEvent.data).payload.originIdentifier,
218
+ destinationId: JSON.parse(event.nativeEvent.data).payload
219
+ .destinationIdentifier,
220
+ directionsOptions: JSON.parse(event.nativeEvent.data).payload
221
+ .directionsOptions,
222
+ });
223
+ break;
224
+ case "navigation.requested":
225
+ startNavigation({
226
+ originId: JSON.parse(event.nativeEvent.data).payload.originIdentifier,
227
+ destinationId: JSON.parse(event.nativeEvent.data).payload
228
+ .destinationIdentifier,
229
+ directionsOptions: JSON.parse(event.nativeEvent.data).payload
230
+ .directionsOptions,
231
+ callback: (status, _navigation?) =>
232
+ status === "success" && navigation
233
+ ? onNavigationRequested({
234
+ navigation: Mapper.routeToResult(_navigation),
235
+ } as OnNavigationResult)
236
+ : status === "error" &&
237
+ onNavigationError({} as OnNavigationResult),
238
+ });
239
+ break;
240
+ case "navigation.stopped":
241
+ stopNavigation();
242
+ break;
243
+ case "cartography.poi_selected":
244
+ onPoiSelected(eventParsed?.payload);
245
+ break;
246
+ case "cartography.poi_deselected":
247
+ onPoiDeselected(eventParsed?.payload);
248
+ break;
249
+ case "cartography.floor_changed":
250
+ onFloorChanged(eventParsed?.payload);
251
+ break;
252
+ case "cartography.building_selected":
253
+ if (
254
+ !eventParsed.payload.identifier ||
255
+ (currentBuilding &&
256
+ eventParsed.payload.identifier.toString() ===
257
+ currentBuilding.buildingIdentifier)
258
+ ) {
259
+ return;
260
+ }
261
+
262
+ initializeBuildingById(eventParsed.payload.identifier.toString());
263
+ break;
264
+ default:
265
+ break;
266
+ }
267
+ };
268
+
269
+ return (
270
+ <WebView
271
+ ref={webViewRef}
272
+ source={{
273
+ uri: `${domain || SITUM_BASE_DOMAIN}/?email=${fullUser?.email}&apikey=${
274
+ fullUser?.apiKey
275
+ }&wl=true&global=true&mode=embed${
276
+ configuration.buildingIdentifier
277
+ ? `&buildingid=${configuration.buildingIdentifier}`
278
+ : ""
279
+ }&show=rts`,
280
+ }}
281
+ style={viewerStyles.webview}
282
+ javaScriptEnabled={true}
283
+ domStorageEnabled={true}
284
+ startInLoadingState={true}
285
+ onMessage={handleRequestFromViewer}
286
+ // This is called on a lot of interactions with the map because of url change probably
287
+ onLoadEnd={() => {
288
+ if (!webViewRef.current) return;
289
+ dispatch(setWebViewRef(webViewRef));
290
+ setMapLoaded(true);
291
+ }}
292
+ onError={(evt: WebViewErrorEvent) => {
293
+ const { nativeEvent } = evt;
294
+ // TODO: on render error should probably still try to render an html
295
+ if (nativeEvent.code === NETWORK_ERROR_CODE[Platform.OS]) {
296
+ onLoadError({
297
+ name: ErrorName.ERR_INTERNET_DISCONNECTED,
298
+ description: nativeEvent.description,
299
+ });
300
+ } else {
301
+ // TODO: handle more errors
302
+ onLoadError({
303
+ name: ErrorName.ERR_INTERNAL_SERVER_ERROR,
304
+ description: nativeEvent.description,
305
+ });
306
+ }
307
+ }}
308
+ />
309
+ );
310
+ };
311
+
312
+ export default MapView;