@situm/react-native 3.3.6 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/android/src/main/java/com/situm/plugin/PluginHelper.java +6 -2
- package/android/src/main/java/com/situm/plugin/SitumMapper.java +17 -7
- package/ios/SitumPlugin.m +22 -6
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sdk/index.js +27 -12
- package/lib/commonjs/sdk/index.js.map +1 -1
- package/lib/commonjs/sdk/types/constants.js +1 -1
- package/lib/commonjs/sdk/types/index.js +352 -0
- package/lib/commonjs/sdk/types/index.js.map +1 -1
- package/lib/commonjs/sdk/utils.js +49 -5
- package/lib/commonjs/sdk/utils.js.map +1 -1
- package/lib/commonjs/utils/requestPermission.js +2 -15
- package/lib/commonjs/utils/requestPermission.js.map +1 -1
- package/lib/commonjs/wayfinding/components/MapView.js +17 -2
- package/lib/commonjs/wayfinding/components/MapView.js.map +1 -1
- package/lib/commonjs/wayfinding/hooks/index.js +6 -8
- package/lib/commonjs/wayfinding/hooks/index.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/sdk/index.js +28 -13
- package/lib/module/sdk/index.js.map +1 -1
- package/lib/module/sdk/types/constants.js +1 -1
- package/lib/module/sdk/types/index.js +382 -1
- package/lib/module/sdk/types/index.js.map +1 -1
- package/lib/module/sdk/utils.js +46 -4
- package/lib/module/sdk/utils.js.map +1 -1
- package/lib/module/utils/requestPermission.js +2 -15
- package/lib/module/utils/requestPermission.js.map +1 -1
- package/lib/module/wayfinding/components/MapView.js +18 -3
- package/lib/module/wayfinding/components/MapView.js.map +1 -1
- package/lib/module/wayfinding/hooks/index.js +6 -8
- package/lib/module/wayfinding/hooks/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/index.d.ts +3 -6
- package/lib/typescript/src/sdk/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/types/constants.d.ts +1 -1
- package/lib/typescript/src/sdk/types/index.d.ts +79 -1
- package/lib/typescript/src/sdk/types/index.d.ts.map +1 -1
- package/lib/typescript/src/sdk/utils.d.ts +1 -0
- package/lib/typescript/src/sdk/utils.d.ts.map +1 -1
- package/lib/typescript/src/utils/requestPermission.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/components/MapView.d.ts +8 -1
- package/lib/typescript/src/wayfinding/components/MapView.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/wayfinding/types/index.d.ts +3 -0
- package/lib/typescript/src/wayfinding/types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/sdk/index.ts +52 -32
- package/src/sdk/types/constants.ts +1 -1
- package/src/sdk/types/index.ts +82 -1
- package/src/sdk/utils.ts +42 -2
- package/src/utils/requestPermission.ts +2 -19
- package/src/wayfinding/components/MapView.tsx +37 -1
- package/src/wayfinding/hooks/index.ts +11 -4
- package/src/wayfinding/types/index.ts +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/wayfinding/hooks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/wayfinding/hooks/index.ts"],"names":[],"mappings":"AA4CA,eAAO,MAAM,gBAAgB;;;;;;;8BAsFY,GAAG;+BAiDR,GAAG;;CAgFtC,CAAC;AAEF,QAAA,MAAM,QAAQ,WAQb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/wayfinding/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE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;AAED,MAAM,WAAW,2BAA2B;IAC1C,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@situm/react-native",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.1",
|
|
4
4
|
"description": "Set of utilities that allow any developer to build React Native location based apps using Situm's indoor positioning system.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": "https://github.com/situmtech/react-native",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"typescript": "tsc --noEmit",
|
|
50
50
|
"lint:fix": "eslint \"src/**/*.{js,ts,tsx}\" --fix",
|
|
51
51
|
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"",
|
|
52
|
-
"prepare": "bob build",
|
|
52
|
+
"prepare": "bob build; yarn doc",
|
|
53
53
|
"release": "release-it",
|
|
54
54
|
"example": "yarn --cwd example",
|
|
55
55
|
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
|
package/src/index.ts
CHANGED
package/src/sdk/index.ts
CHANGED
|
@@ -6,28 +6,34 @@ import { NativeEventEmitter, NativeModules, Platform } from "react-native";
|
|
|
6
6
|
import packageJson from "../../package.json";
|
|
7
7
|
import { logError } from "../utils/logError";
|
|
8
8
|
import type { SitumPluginInterface } from "./nativeInterface";
|
|
9
|
-
import
|
|
10
|
-
Building,
|
|
11
|
-
BuildingInfo,
|
|
12
|
-
ConfigurationOptions,
|
|
13
|
-
Directions,
|
|
14
|
-
DirectionsOptions,
|
|
15
|
-
Error,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
import {
|
|
10
|
+
type Building,
|
|
11
|
+
type BuildingInfo,
|
|
12
|
+
type ConfigurationOptions,
|
|
13
|
+
type Directions,
|
|
14
|
+
type DirectionsOptions,
|
|
15
|
+
type Error,
|
|
16
|
+
ErrorCode,
|
|
17
|
+
ErrorType,
|
|
18
|
+
type Floor,
|
|
19
|
+
type Geofence,
|
|
20
|
+
type Location,
|
|
21
|
+
type LocationRequest,
|
|
22
|
+
type LocationStatus,
|
|
23
|
+
type NavigationProgress,
|
|
24
|
+
type NavigationRequest,
|
|
25
|
+
type Poi,
|
|
26
|
+
type PoiCategory,
|
|
27
|
+
type PoiIcon,
|
|
28
|
+
type Point,
|
|
29
|
+
type SdkVersion,
|
|
28
30
|
} from "./types";
|
|
29
31
|
import { SdkNavigationUpdateType } from "./types/constants";
|
|
30
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
exceptionWrapper,
|
|
34
|
+
locationErrorAdapter,
|
|
35
|
+
promiseWrapper,
|
|
36
|
+
} from "./utils";
|
|
31
37
|
|
|
32
38
|
export type * from "./types";
|
|
33
39
|
export * from "./types/constants";
|
|
@@ -233,13 +239,24 @@ export default class SitumPlugin {
|
|
|
233
239
|
|
|
234
240
|
/**
|
|
235
241
|
* Returns the device identifier that has generated the location
|
|
236
|
-
*
|
|
237
|
-
* @returns void
|
|
238
|
-
* @throw Exception
|
|
239
242
|
*/
|
|
240
243
|
static getDeviceId = () => {
|
|
241
|
-
return
|
|
242
|
-
RNCSitumPlugin.getDeviceId(
|
|
244
|
+
return promiseWrapper<string>(({ onSuccess, onError }) => {
|
|
245
|
+
RNCSitumPlugin.getDeviceId((response) => {
|
|
246
|
+
//@ts-ignore
|
|
247
|
+
if (response?.deviceId) {
|
|
248
|
+
// Resolve with the actual deviceId
|
|
249
|
+
//@ts-ignore
|
|
250
|
+
onSuccess(response.deviceId);
|
|
251
|
+
} else {
|
|
252
|
+
// Reject if deviceId is not available in the response
|
|
253
|
+
onError({
|
|
254
|
+
code: ErrorCode.UNKNOWN,
|
|
255
|
+
message: "Couldn't get device ID",
|
|
256
|
+
type: ErrorType.CRITICAL,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
});
|
|
243
260
|
});
|
|
244
261
|
};
|
|
245
262
|
|
|
@@ -461,13 +478,11 @@ export default class SitumPlugin {
|
|
|
461
478
|
*/
|
|
462
479
|
static removeNavigationUpdates = () => {
|
|
463
480
|
return promiseWrapper<void>(({ onCallback }) => {
|
|
464
|
-
if (!SitumPlugin.navigationIsRunning())
|
|
465
|
-
throw "Situm > hook > Navigation updates were not active.";
|
|
466
|
-
}
|
|
481
|
+
if (!SitumPlugin.navigationIsRunning()) return;
|
|
467
482
|
|
|
468
483
|
navigationRunning = false;
|
|
469
|
-
RNCSitumPlugin.removeNavigationUpdates((
|
|
470
|
-
onCallback(
|
|
484
|
+
RNCSitumPlugin.removeNavigationUpdates((response) => {
|
|
485
|
+
onCallback(response, "Failed to remove navigation updates");
|
|
471
486
|
});
|
|
472
487
|
});
|
|
473
488
|
};
|
|
@@ -576,8 +591,13 @@ export default class SitumPlugin {
|
|
|
576
591
|
*
|
|
577
592
|
* @param callback the function called when there is an error
|
|
578
593
|
*/
|
|
579
|
-
static onLocationError = (callback: (
|
|
580
|
-
SitumPluginEventEmitter.addListener("locationError",
|
|
594
|
+
static onLocationError = (callback: (error: Error) => void) => {
|
|
595
|
+
SitumPluginEventEmitter.addListener("locationError", (error) => {
|
|
596
|
+
const adaptedError = locationErrorAdapter(error);
|
|
597
|
+
if (adaptedError.type === ErrorType.CRITICAL)
|
|
598
|
+
this.removeLocationUpdates();
|
|
599
|
+
callback(adaptedError);
|
|
600
|
+
});
|
|
581
601
|
};
|
|
582
602
|
|
|
583
603
|
/**
|
|
@@ -30,7 +30,7 @@ export enum LocationStatusName {
|
|
|
30
30
|
/**
|
|
31
31
|
* Available accessibility modes used in the {@link DirectionsRequest}.
|
|
32
32
|
*
|
|
33
|
-
* @property CHOOSE_SHORTEST The route should choose the best route, without taking into account if it is accessible or not
|
|
33
|
+
* @property CHOOSE_SHORTEST The route should choose the best route, without taking into account if it is accessible or not.
|
|
34
34
|
* This option is the default so you don't have to do anything in order to use it
|
|
35
35
|
* @property ONLY_ACCESSIBLE The route should always use accessible nodes.
|
|
36
36
|
* @property ONLY_NOT_ACCESSIBLE_FLOOR_CHANGES The route should never use accessible floor changes (use this to force routes not to use lifts).
|
package/src/sdk/types/index.ts
CHANGED
|
@@ -496,17 +496,45 @@ export type RealTimeData = {
|
|
|
496
496
|
locations: Location[];
|
|
497
497
|
};
|
|
498
498
|
|
|
499
|
+
/**
|
|
500
|
+
* @name SdkVersion
|
|
501
|
+
* @description Represents the version information of the SDK and its compatibility with different platforms.
|
|
502
|
+
*
|
|
503
|
+
* @type
|
|
504
|
+
* @property {string} react_native - The version of React Native used in the SDK.
|
|
505
|
+
* @property {string} [ios] - Optional. The specific version of the Situm SDK for the iOS platform.
|
|
506
|
+
* @property {string} [android] - Optional. The specific version of the Situm SDK for the Android platform.
|
|
507
|
+
*/
|
|
499
508
|
export type SdkVersion = {
|
|
500
509
|
react_native: string;
|
|
501
510
|
ios?: string;
|
|
502
511
|
android?: string;
|
|
503
512
|
};
|
|
504
513
|
|
|
514
|
+
/**
|
|
515
|
+
* @name ConfigurationOptions
|
|
516
|
+
* @description Configuration options for initializing the SDK or other modules.
|
|
517
|
+
*
|
|
518
|
+
* @type
|
|
519
|
+
* @property {boolean} [useRemoteConfig] - Optional. Determines whether to use Remote Configuration settings.
|
|
520
|
+
* @property {number} [cacheMaxAge] - Optional. The maximum age of the cache in seconds.
|
|
521
|
+
*/
|
|
505
522
|
export type ConfigurationOptions = {
|
|
506
523
|
useRemoteConfig?: boolean;
|
|
507
524
|
cacheMaxAge?: number;
|
|
508
525
|
};
|
|
509
526
|
|
|
527
|
+
/**
|
|
528
|
+
* @name Location
|
|
529
|
+
* @description Represents a location with various attributes including position, accuracy, and bearing.
|
|
530
|
+
*
|
|
531
|
+
* @interface
|
|
532
|
+
* @property {Position} [position] - Optional. The position information of the location.
|
|
533
|
+
* @property {number} [accuracy] - Optional. The accuracy of the location information in meters.
|
|
534
|
+
* @property {Object} [bearing] - Optional. Bearing information including degrees and degreesClockwise.
|
|
535
|
+
* @property {boolean} [hasBearing] - Optional. Indicates if bearing information is available.
|
|
536
|
+
* @property {LocationStatusName} status - The status of the location update.
|
|
537
|
+
*/
|
|
510
538
|
export interface Location {
|
|
511
539
|
position?: Position;
|
|
512
540
|
accuracy?: number;
|
|
@@ -532,14 +560,67 @@ export interface Position {
|
|
|
532
560
|
buildingIdentifier?: string;
|
|
533
561
|
floorIdentifier?: string;
|
|
534
562
|
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* @name LocationStatus
|
|
566
|
+
* @description Represents the status of a location, including a name and a numeric code.
|
|
567
|
+
*
|
|
568
|
+
* @interface
|
|
569
|
+
* @property {LocationStatusName} statusName - The name of the location status.
|
|
570
|
+
* @property {number} statusCode - The numeric code representing the location status.
|
|
571
|
+
*/
|
|
535
572
|
export interface LocationStatus {
|
|
536
573
|
statusName: LocationStatusName;
|
|
537
574
|
statusCode: number;
|
|
538
575
|
}
|
|
539
576
|
|
|
577
|
+
/**
|
|
578
|
+
* @name ErrorType
|
|
579
|
+
* @description Enumeration of error types to categorize the severity of errors.
|
|
580
|
+
*
|
|
581
|
+
* @enum {string}
|
|
582
|
+
* @property {string} CRITICAL - Represents critical errors that will cause the system not to work (e.g. positioning will be stopped).
|
|
583
|
+
* @property {string} NON_CRITICAL - Represents non-critical errors that are less severe.
|
|
584
|
+
*/
|
|
585
|
+
export enum ErrorType {
|
|
586
|
+
CRITICAL = "CRITICAL",
|
|
587
|
+
NON_CRITICAL = "NON_CRITICAL",
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* @name ErrorCode
|
|
592
|
+
* @description Enumeration of error codes provided by Situm SDK.
|
|
593
|
+
*
|
|
594
|
+
* @enum {string}
|
|
595
|
+
* @property {string} LOCATION_PERMISSION_DENIED - Indicates that location permissions were not granted by the user.
|
|
596
|
+
* @property {string} BLUETOOTH_PERMISSION_DENIED - Indicates that Bluetooth permissions were not granted.
|
|
597
|
+
* @property {string} BLUETOOTH_DISABLED - Indicates that Bluetooth is disabled on the device.
|
|
598
|
+
* @property {string} LOCATION_DISABLED - Indicates that the location services are disabled on the device.
|
|
599
|
+
* @property {string} REDUCED_ACCURACY - Indicates that the precise location has been turned off on the device.
|
|
600
|
+
* @property {string} UNKNOWN - Represents an unknown error or an error that does not fit other categories.
|
|
601
|
+
*/
|
|
602
|
+
export enum ErrorCode {
|
|
603
|
+
LOCATION_PERMISSION_DENIED = "LOCATION_PERMISSION_DENIED",
|
|
604
|
+
BLUETOOTH_PERMISSION_DENIED = "BLUETOOTH_PERMISSION_DENIED",
|
|
605
|
+
BLUETOOTH_DISABLED = "BLUETOOTH_DISABLED",
|
|
606
|
+
LOCATION_DISABLED = "LOCATION_DISABLED",
|
|
607
|
+
REDUCED_ACCURACY = "REDUCED_ACCURACY",
|
|
608
|
+
UNKNOWN = "UNKNOWN",
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* @name Error
|
|
613
|
+
* @description Represents an error with a specific code, message, and type.
|
|
614
|
+
*
|
|
615
|
+
* @interface
|
|
616
|
+
* @property {ErrorCode} code - The specific error code associated with this error.
|
|
617
|
+
* @property {string} message - A descriptive message providing more details about the error.
|
|
618
|
+
* @property {ErrorType} type - The type of the error indicating its severity (critical or non-critical).
|
|
619
|
+
*/
|
|
540
620
|
export interface Error {
|
|
541
|
-
code
|
|
621
|
+
code: ErrorCode;
|
|
542
622
|
message: string;
|
|
623
|
+
type: ErrorType;
|
|
543
624
|
}
|
|
544
625
|
|
|
545
626
|
// TODO: add types
|
package/src/sdk/utils.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { logError } from "..";
|
|
2
2
|
import type { Error } from "./types";
|
|
3
|
+
import { ErrorCode, ErrorType } from "./types";
|
|
3
4
|
|
|
4
5
|
type PromiseResolve<T> = (response: T) => void;
|
|
5
6
|
type PromiseReject = (error?: Error) => void;
|
|
@@ -23,8 +24,9 @@ export const handleAsyncCallback = (
|
|
|
23
24
|
resolve();
|
|
24
25
|
} else {
|
|
25
26
|
reject({
|
|
26
|
-
code:
|
|
27
|
+
code: ErrorCode.UNKNOWN,
|
|
27
28
|
message: errorMessage || "Unknown error.",
|
|
29
|
+
type: ErrorType.NON_CRITICAL,
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
32
|
};
|
|
@@ -121,9 +123,47 @@ export const promiseWrapper = <T>(
|
|
|
121
123
|
} catch (error) {
|
|
122
124
|
logError(error);
|
|
123
125
|
reject({
|
|
124
|
-
code:
|
|
126
|
+
code: ErrorCode.UNKNOWN,
|
|
125
127
|
message: error?.message || "Unknown error.",
|
|
128
|
+
type: ErrorType.NON_CRITICAL,
|
|
126
129
|
});
|
|
127
130
|
}
|
|
128
131
|
});
|
|
129
132
|
};
|
|
133
|
+
|
|
134
|
+
export function locationErrorAdapter(error): Error {
|
|
135
|
+
let adaptedCode = ErrorCode.UNKNOWN;
|
|
136
|
+
const adaptedMessage = error.message;
|
|
137
|
+
const adaptedType = ErrorType.CRITICAL;
|
|
138
|
+
|
|
139
|
+
switch (error.code.toString()) {
|
|
140
|
+
case "8001": // MISSING_LOCATION_PERMISSION
|
|
141
|
+
case "8": // kSITLocationErrorLocationDisabled
|
|
142
|
+
case "9": // kSITLocationErrorLocationRestricted
|
|
143
|
+
case "10": // kSITLocationErrorLocationAuthStatusNotDetermined
|
|
144
|
+
adaptedCode = ErrorCode.LOCATION_PERMISSION_DENIED;
|
|
145
|
+
break;
|
|
146
|
+
case "8002": // LOCATION_DISABLED
|
|
147
|
+
adaptedCode = ErrorCode.LOCATION_DISABLED;
|
|
148
|
+
break;
|
|
149
|
+
case "8012": // MISSING_BLUETOOTH_PERMISSION
|
|
150
|
+
adaptedCode = ErrorCode.BLUETOOTH_PERMISSION_DENIED;
|
|
151
|
+
break;
|
|
152
|
+
case "8100": //BLUETOOTH_DISABLED. 8100 ->This number does not exist in Situm SDK. We made it up in SitumMapper.java (RN adapter)
|
|
153
|
+
case "6": // kSITLocationErrorBluetoothisOff
|
|
154
|
+
adaptedCode = ErrorCode.BLUETOOTH_DISABLED;
|
|
155
|
+
break;
|
|
156
|
+
case "11": //kSITLocationErrorLocationAccuracyAuthorizationStatusReducedAccuracy
|
|
157
|
+
adaptedCode = ErrorCode.REDUCED_ACCURACY;
|
|
158
|
+
break;
|
|
159
|
+
// Add more cases as needed
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const returnError: Error = {
|
|
163
|
+
code: adaptedCode,
|
|
164
|
+
message: adaptedMessage,
|
|
165
|
+
type: adaptedType,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return returnError;
|
|
169
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// TODO: can requestMultiple be used ?
|
|
10
10
|
const checkIOSPermissions = async () => {
|
|
11
|
-
|
|
11
|
+
const granted = await request(PERMISSIONS.IOS.LOCATION_WHEN_IN_USE);
|
|
12
12
|
|
|
13
13
|
// Check if already denied
|
|
14
14
|
if (granted !== RESULTS.GRANTED) {
|
|
@@ -19,24 +19,7 @@ const checkIOSPermissions = async () => {
|
|
|
19
19
|
"Situm > permissions > LOCATION_WHEN_IN_USE permission granted"
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
if (parseInt(Platform.Version, 10) > 12) {
|
|
24
|
-
granted = await request(PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL);
|
|
25
|
-
|
|
26
|
-
if (granted === RESULTS.GRANTED) {
|
|
27
|
-
console.debug(
|
|
28
|
-
"Situm > permissions > BLUETOOTH_PERIPHERAL permission granted"
|
|
29
|
-
);
|
|
30
|
-
return true;
|
|
31
|
-
} else {
|
|
32
|
-
throw "Situm > permissions > BLUETOOTH_PERIPHERAL permission not granted";
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
console.debug(
|
|
36
|
-
"Situm > permissions > BLUETOOTH_PERIPHERAL permissions not required"
|
|
37
|
-
);
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
22
|
+
return true;
|
|
40
23
|
};
|
|
41
24
|
|
|
42
25
|
const checkAndroidPermissions = async () => {
|
|
@@ -8,6 +8,7 @@ import React, {
|
|
|
8
8
|
useState,
|
|
9
9
|
} from "react";
|
|
10
10
|
import {
|
|
11
|
+
Linking,
|
|
11
12
|
Platform,
|
|
12
13
|
type StyleProp,
|
|
13
14
|
StyleSheet,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
type MapViewRef,
|
|
27
28
|
type NavigateToPointPayload,
|
|
28
29
|
type NavigateToPoiPayload,
|
|
30
|
+
type OnExternalLinkClickedResult,
|
|
29
31
|
type OnFloorChangedResult,
|
|
30
32
|
type OnPoiDeselectedResult,
|
|
31
33
|
type OnPoiSelectedResult,
|
|
@@ -69,6 +71,13 @@ export interface MapViewProps {
|
|
|
69
71
|
onLoad?: (event: any) => void;
|
|
70
72
|
onLoadError?: (event: MapViewError) => void;
|
|
71
73
|
onFloorChanged?: (event: OnFloorChangedResult) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Callback invoked when the user clicks on a link in the MapView that leads to a website different from the MapView's domain.
|
|
76
|
+
* If this callback is not set, the link will be opened in the system's default browser by default.
|
|
77
|
+
* @param event OnExternalLinkClickedResult object.
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
onExternalLinkClicked?: (event: OnExternalLinkClickedResult) => void;
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
const MapView = React.forwardRef<MapViewRef, MapViewProps>(
|
|
@@ -81,6 +90,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
|
|
|
81
90
|
onPoiSelected = () => {},
|
|
82
91
|
onPoiDeselected = () => {},
|
|
83
92
|
onFloorChanged = () => {},
|
|
93
|
+
onExternalLinkClicked = undefined,
|
|
84
94
|
},
|
|
85
95
|
ref
|
|
86
96
|
) => {
|
|
@@ -230,7 +240,13 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
|
|
|
230
240
|
},
|
|
231
241
|
};
|
|
232
242
|
},
|
|
233
|
-
[
|
|
243
|
+
[
|
|
244
|
+
stopNavigation,
|
|
245
|
+
_navigateToPoi,
|
|
246
|
+
_navigateToPoint,
|
|
247
|
+
_selectPoi,
|
|
248
|
+
_selectPoiCategory,
|
|
249
|
+
]
|
|
234
250
|
);
|
|
235
251
|
|
|
236
252
|
useEffect(() => {
|
|
@@ -344,6 +360,25 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
|
|
|
344
360
|
}
|
|
345
361
|
};
|
|
346
362
|
|
|
363
|
+
const _onShouldStartLoadWithRequest = (request) => {
|
|
364
|
+
if (
|
|
365
|
+
request &&
|
|
366
|
+
request.url &&
|
|
367
|
+
!request.url.startsWith(configuration.viewerDomain || SITUM_BASE_DOMAIN)
|
|
368
|
+
) {
|
|
369
|
+
if (
|
|
370
|
+
onExternalLinkClicked &&
|
|
371
|
+
typeof onExternalLinkClicked === "function"
|
|
372
|
+
) {
|
|
373
|
+
onExternalLinkClicked({ url: request.url });
|
|
374
|
+
} else {
|
|
375
|
+
Linking.openURL(request.url);
|
|
376
|
+
}
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
return true;
|
|
380
|
+
};
|
|
381
|
+
|
|
347
382
|
return (
|
|
348
383
|
<WebView
|
|
349
384
|
ref={webViewRef}
|
|
@@ -367,6 +402,7 @@ const MapView = React.forwardRef<MapViewRef, MapViewProps>(
|
|
|
367
402
|
startInLoadingState={true}
|
|
368
403
|
cacheEnabled
|
|
369
404
|
onMessage={handleRequestFromViewer}
|
|
405
|
+
onShouldStartLoadWithRequest={_onShouldStartLoadWithRequest}
|
|
370
406
|
onError={(evt: WebViewErrorEvent) => {
|
|
371
407
|
if (!onLoadError) return;
|
|
372
408
|
const { nativeEvent } = evt;
|
|
@@ -5,6 +5,8 @@ import SitumPlugin from "../../sdk";
|
|
|
5
5
|
import {
|
|
6
6
|
type Building,
|
|
7
7
|
type Error,
|
|
8
|
+
ErrorCode,
|
|
9
|
+
ErrorType,
|
|
8
10
|
type Location,
|
|
9
11
|
type LocationStatus,
|
|
10
12
|
type NavigationProgress,
|
|
@@ -77,8 +79,6 @@ export const useSitumInternal = () => {
|
|
|
77
79
|
|
|
78
80
|
SitumPlugin.onLocationError((err: Error) => {
|
|
79
81
|
console.error(`Situm > hook > Error while positioning: ${err}}`);
|
|
80
|
-
//@ts-ignore
|
|
81
|
-
dispatch(setError({ message: err, code: 3001 } as SDKError));
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
SitumPlugin.onLocationStopped(() => {
|
|
@@ -207,7 +207,14 @@ export const useSitumInternal = () => {
|
|
|
207
207
|
});
|
|
208
208
|
} catch (e) {
|
|
209
209
|
console.error(`Situm > hook > Could not update navigation ${e}`);
|
|
210
|
-
|
|
210
|
+
//TODO: Remove this and emit these errors in SitumPlugin.onNavigationError
|
|
211
|
+
dispatch(
|
|
212
|
+
setError({
|
|
213
|
+
message: "Could not update navigation",
|
|
214
|
+
code: ErrorCode.UNKNOWN,
|
|
215
|
+
type: ErrorType.NON_CRITICAL,
|
|
216
|
+
} as Error)
|
|
217
|
+
);
|
|
211
218
|
stopNavigation();
|
|
212
219
|
}
|
|
213
220
|
})
|
|
@@ -219,11 +226,11 @@ export const useSitumInternal = () => {
|
|
|
219
226
|
};
|
|
220
227
|
|
|
221
228
|
const stopNavigation = () => {
|
|
222
|
-
console.debug("Situm > hook > Stopping navigation");
|
|
223
229
|
// TODO: we should delegate this to the sdk plugin
|
|
224
230
|
if (!navigation || navigation?.status === NavigationStatus.STOP) {
|
|
225
231
|
return;
|
|
226
232
|
}
|
|
233
|
+
console.debug("Situm > hook > Stopping navigation");
|
|
227
234
|
|
|
228
235
|
SitumPlugin.removeNavigationUpdates()
|
|
229
236
|
.then(() => {
|