react-native-pointr 9.5.0 → 9.7.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 (79) hide show
  1. package/API_REFERENCE.md +1035 -557
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +75 -216
  4. package/android/build.gradle +1 -1
  5. package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +156 -0
  6. package/ios/PTRMapWidgetContainerView.swift +179 -1
  7. package/ios/PTRMapWidgetManager-Bridging.m +6 -0
  8. package/ios/PTRNativeLibrary.swift +14 -0
  9. package/package.json +30 -6
  10. package/react-native-pointr.podspec +1 -1
  11. package/src/PTRMapWidgetUtils.ts +2 -8
  12. package/src/api/MapWidgetApi.ts +45 -0
  13. package/src/api/PointrSdk.ts +241 -0
  14. package/src/api/index.ts +9 -0
  15. package/src/commands/index.ts +275 -0
  16. package/src/components/index.tsx +130 -0
  17. package/src/constants/index.ts +104 -0
  18. package/src/hooks/index.ts +8 -0
  19. package/src/hooks/usePointrEvents.ts +40 -0
  20. package/src/hooks/usePointrPois.ts +41 -0
  21. package/src/hooks/usePointrPosition.ts +31 -0
  22. package/src/hooks/usePointrSdk.ts +41 -0
  23. package/src/index.tsx +87 -7
  24. package/src/{PTRPoiManager.ts → managers/PTRPoiManager.ts} +1 -1
  25. package/src/types/config.ts +57 -0
  26. package/src/types/events.ts +106 -0
  27. package/src/types/index.ts +35 -0
  28. package/.vscode/settings.json +0 -21
  29. package/example/pointr_rn_demo/.bundle/config +0 -2
  30. package/example/pointr_rn_demo/.eslintrc.js +0 -4
  31. package/example/pointr_rn_demo/.prettierrc.js +0 -5
  32. package/example/pointr_rn_demo/.watchmanconfig +0 -1
  33. package/example/pointr_rn_demo/App.tsx +0 -323
  34. package/example/pointr_rn_demo/Gemfile +0 -16
  35. package/example/pointr_rn_demo/Gemfile.lock +0 -111
  36. package/example/pointr_rn_demo/README.md +0 -188
  37. package/example/pointr_rn_demo/__tests__/App.test.tsx +0 -13
  38. package/example/pointr_rn_demo/android/app/build.gradle +0 -119
  39. package/example/pointr_rn_demo/android/app/debug.keystore +0 -0
  40. package/example/pointr_rn_demo/android/app/proguard-rules.pro +0 -10
  41. package/example/pointr_rn_demo/android/app/src/main/AndroidManifest.xml +0 -27
  42. package/example/pointr_rn_demo/android/app/src/main/java/com/pointr_rn_demo/MainActivity.kt +0 -22
  43. package/example/pointr_rn_demo/android/app/src/main/java/com/pointr_rn_demo/MainApplication.kt +0 -27
  44. package/example/pointr_rn_demo/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -37
  45. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  46. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  47. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  48. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  49. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  50. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  51. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  52. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  53. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  54. package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  55. package/example/pointr_rn_demo/android/app/src/main/res/values/strings.xml +0 -3
  56. package/example/pointr_rn_demo/android/app/src/main/res/values/styles.xml +0 -9
  57. package/example/pointr_rn_demo/android/build.gradle +0 -34
  58. package/example/pointr_rn_demo/android/gradle.properties +0 -44
  59. package/example/pointr_rn_demo/android/settings.gradle +0 -6
  60. package/example/pointr_rn_demo/app.json +0 -4
  61. package/example/pointr_rn_demo/babel.config.js +0 -3
  62. package/example/pointr_rn_demo/index.js +0 -16
  63. package/example/pointr_rn_demo/ios/.xcode.env +0 -11
  64. package/example/pointr_rn_demo/ios/Podfile +0 -40
  65. package/example/pointr_rn_demo/ios/pointr_rn_demo/AppDelegate.swift +0 -48
  66. package/example/pointr_rn_demo/ios/pointr_rn_demo/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
  67. package/example/pointr_rn_demo/ios/pointr_rn_demo/Images.xcassets/Contents.json +0 -6
  68. package/example/pointr_rn_demo/ios/pointr_rn_demo/Info.plist +0 -63
  69. package/example/pointr_rn_demo/ios/pointr_rn_demo/LaunchScreen.storyboard +0 -47
  70. package/example/pointr_rn_demo/ios/pointr_rn_demo/PrivacyInfo.xcprivacy +0 -37
  71. package/example/pointr_rn_demo/ios/pointr_rn_demo.xcodeproj/project.pbxproj +0 -488
  72. package/example/pointr_rn_demo/ios/pointr_rn_demo.xcodeproj/xcshareddata/xcschemes/pointr_rn_demo.xcscheme +0 -88
  73. package/example/pointr_rn_demo/ios/pointr_rn_demo.xcworkspace/contents.xcworkspacedata +0 -10
  74. package/example/pointr_rn_demo/jest.config.js +0 -3
  75. package/example/pointr_rn_demo/metro.config.js +0 -22
  76. package/example/pointr_rn_demo/package.json +0 -47
  77. package/example/pointr_rn_demo/prepare-demo-distribution.sh +0 -103
  78. package/example/pointr_rn_demo/tsconfig.json +0 -5
  79. package/prepare-distribution.sh +0 -151
package/src/index.tsx CHANGED
@@ -17,18 +17,45 @@ const PTRNativePointrLibrary = NativeModules.PTRNativePointrLibrary
17
17
  }
18
18
  );
19
19
 
20
- // Export the native library as default
20
+ // Export the native library as default (backwards compatibility)
21
21
  export default PTRNativePointrLibrary;
22
22
 
23
- // Export POI Manager functions
24
- export { getPois } from './PTRPoiManager';
23
+ // ============================================================================
24
+ // NEW API - Recommended for new projects
25
+ // ============================================================================
25
26
 
26
- // Export Map Widget utilities
27
- export { showMapWidget } from './PTRMapWidgetUtils';
27
+ // Core API
28
+ export { PointrSdk, pointrSdk } from './api/PointrSdk';
29
+ export {
30
+ executeMapCommand,
31
+ } from './api/MapWidgetApi';
28
32
 
29
- // Export PTR Commands
33
+ // Constants and Enums
30
34
  export {
35
+ PTRLogLevel,
36
+ PTRState,
37
+ PTRAnimationType,
31
38
  PTRCommandType,
39
+ PTREvents,
40
+ PTRErrorMessages,
41
+ } from './constants';
42
+
43
+ // React Hooks
44
+ export {
45
+ usePointrSdk,
46
+ usePointrPosition,
47
+ usePointrPois,
48
+ usePointrGeofence,
49
+ usePointrBuildingClick,
50
+ usePointrSiteClick,
51
+ } from './hooks';
52
+
53
+ // Components
54
+ export { PTRMapWidget } from './components';
55
+ export type { PTRMapWidgetProps } from './components';
56
+
57
+ // Commands (new refactored version)
58
+ export {
32
59
  PTRCommand,
33
60
  PTRSiteCommand,
34
61
  PTRBuildingCommand,
@@ -41,9 +68,58 @@ export {
41
68
  PTRMarkMyCarSiteCommand,
42
69
  PTRShowMyCarSiteCommand,
43
70
  PTRStartAndFocusCommand,
71
+ isPTRSiteCommand,
72
+ isPTRBuildingCommand,
73
+ isPTRLevelCommand,
74
+ isPTRPoiCommand,
75
+ isPTRPathCommand,
76
+ isPTRStaticPathCommand,
77
+ } from './commands';
78
+
79
+ // Types
80
+ export type {
81
+ PTRConfiguration,
82
+ PTRMapWidgetConfiguration,
83
+ PTRStateCallback,
84
+ PTRPositionEvent,
85
+ PTRBuildingClickEvent,
86
+ PTRSiteClickEvent,
87
+ PTRGeofenceEvent,
88
+ PTRGeofence,
89
+ PTRGeofenceNotification,
90
+ PTRMapCommandResponse,
91
+ } from './types';
92
+
93
+ export { PTRGeofenceEventType } from './types';
94
+
95
+ // ============================================================================
96
+ // LEGACY API - Maintained for backwards compatibility
97
+ // ============================================================================
98
+
99
+ // Export POI Manager functions (legacy)
100
+ export { getPois } from './managers/PTRPoiManager';
101
+
102
+ // Export Map Widget utilities (legacy)
103
+ export { showMapWidget } from './PTRMapWidgetUtils';
104
+
105
+ // Legacy command exports (still works but new code should use ./commands)
106
+ export {
107
+ PTRCommandType as LegacyPTRCommandType,
108
+ PTRCommand as LegacyPTRCommand,
109
+ PTRSiteCommand as LegacyPTRSiteCommand,
110
+ PTRBuildingCommand as LegacyPTRBuildingCommand,
111
+ PTRLevelCommand as LegacyPTRLevelCommand,
112
+ PTRPoiCommand as LegacyPTRPoiCommand,
113
+ PTRPathCommand as LegacyPTRPathCommand,
114
+ PTRStaticPathCommand as LegacyPTRStaticPathCommand,
115
+ PTRStaticWayfindingCommand as LegacyPTRStaticWayfindingCommand,
116
+ PTRMarkMyCarLevelCommand as LegacyPTRMarkMyCarLevelCommand,
117
+ PTRMarkMyCarSiteCommand as LegacyPTRMarkMyCarSiteCommand,
118
+ PTRShowMyCarSiteCommand as LegacyPTRShowMyCarSiteCommand,
119
+ PTRStartAndFocusCommand as LegacyPTRStartAndFocusCommand,
44
120
  } from './PTRCommand';
45
121
 
46
- // Export types
122
+ // Export all existing types (maintained for backwards compatibility)
47
123
  export type { PTRPoi, PTRPoiAttributes } from './types/PTRPoi';
48
124
  export type { PTRPosition } from './types/PTRPosition';
49
125
  export type { PTRWayfindingEvent } from './types/PTRWayfindingEvent';
@@ -57,3 +133,7 @@ export type {
57
133
  PTRGeoMultiPolygon,
58
134
  PTRGeoCircle,
59
135
  } from './types/PTRGeometry';
136
+
137
+ // Re-export native module reference
138
+ export { PTRNativePointrLibrary };
139
+
@@ -1,5 +1,5 @@
1
1
  import { NativeModules } from 'react-native';
2
- import { PTRPoi } from './types/PTRPoi';
2
+ import { PTRPoi } from '../types/PTRPoi';
3
3
 
4
4
  const { PTRNativePointrLibrary } = NativeModules;
5
5
 
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Configuration types for the Pointr SDK
3
+ * @module types/config
4
+ */
5
+
6
+ import { PTRLogLevel } from '../constants';
7
+
8
+ /**
9
+ * Configuration options for initializing the Pointr SDK
10
+ */
11
+ export interface PTRConfiguration {
12
+ /** Client ID provided by Pointr */
13
+ readonly clientId: string;
14
+ /** License key provided by Pointr */
15
+ readonly licenseKey: string;
16
+ /** Base URL for the Pointr service */
17
+ readonly baseUrl: string;
18
+ /** Log level for SDK output (default: ERROR) */
19
+ readonly logLevel?: PTRLogLevel;
20
+ }
21
+
22
+ /**
23
+ * Map widget configuration options
24
+ */
25
+ export interface PTRMapWidgetConfiguration {
26
+ /** Show/hide the level selector UI */
27
+ readonly isLevelSelectorEnabled?: boolean;
28
+ /** Show/hide the loading view */
29
+ readonly isLoadingViewEnabled?: boolean;
30
+ /** Show/hide the map tracking mode button */
31
+ readonly isMapTrackingModeButtonEnabled?: boolean;
32
+ /** Show/hide the exit button */
33
+ readonly isExitButtonEnabled?: boolean;
34
+ /** Show/hide the splash screen */
35
+ readonly isSplashScreenEnabled?: boolean;
36
+ /** Enable/disable the onboarding flow */
37
+ readonly isOnboardingEnabled?: boolean;
38
+ /** Show/hide the joystick control */
39
+ readonly isJoystickEnabled?: boolean;
40
+ /** Show/hide toast messages */
41
+ readonly isToastMessagesEnabled?: boolean;
42
+ /** Show/hide the info button */
43
+ readonly isInfoButtonEnabled?: boolean;
44
+ /** Show/hide the location indicator */
45
+ readonly isLocationIndicatorEnabled?: boolean;
46
+ /** Automatically pan map to first calculated user position */
47
+ readonly shouldFocusOnFirstUserPosition?: boolean;
48
+ /** Enable/disable quick access panel */
49
+ readonly isQuickAccessEnabled?: boolean;
50
+ /** Show/hide the app banner */
51
+ readonly isAppBannerEnabled?: boolean;
52
+ }
53
+
54
+ /**
55
+ * Callback function for SDK state changes
56
+ */
57
+ export type PTRStateCallback = (state: string) => void;
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Event types for the Pointr SDK
3
+ * @module types/events
4
+ */
5
+
6
+ import type { PTRPosition } from './PTRPosition';
7
+
8
+ /**
9
+ * Position event payload
10
+ */
11
+ export interface PTRPositionEvent {
12
+ /** Geographic position */
13
+ readonly position: PTRPosition;
14
+ /** Timestamp of the position calculation */
15
+ readonly timestamp?: number;
16
+ /** Accuracy of the position in meters */
17
+ readonly accuracy?: number;
18
+ }
19
+
20
+ /**
21
+ * Building click event payload
22
+ */
23
+ export interface PTRBuildingClickEvent {
24
+ /** Site identifier */
25
+ readonly siteId: string;
26
+ /** Building identifier */
27
+ readonly buildingId: string;
28
+ /** Building name */
29
+ readonly buildingName?: string;
30
+ }
31
+
32
+ /**
33
+ * Site click event payload
34
+ */
35
+ export interface PTRSiteClickEvent {
36
+ /** Site identifier */
37
+ readonly siteId: string;
38
+ /** Site name */
39
+ readonly siteName?: string;
40
+ }
41
+
42
+ /**
43
+ * Geofence event types
44
+ */
45
+ export enum PTRGeofenceEventType {
46
+ /** User entered a geofence */
47
+ ENTER = 'enter',
48
+ /** User exited a geofence */
49
+ EXIT = 'exit',
50
+ /** User is dwelling in a geofence */
51
+ DWELL = 'dwell',
52
+ }
53
+
54
+ /**
55
+ * Geofence data
56
+ */
57
+ export interface PTRGeofence {
58
+ /** Geofence identifier */
59
+ readonly id: string;
60
+ /** External identifier */
61
+ readonly externalId?: string;
62
+ /** Geofence name */
63
+ readonly name: string;
64
+ /** Geofence type */
65
+ readonly geofenceType: string;
66
+ /** Position of the geofence */
67
+ readonly position: PTRPosition;
68
+ }
69
+
70
+ /**
71
+ * Geofence notification
72
+ */
73
+ export interface PTRGeofenceNotification {
74
+ /** Notification identifier */
75
+ readonly id: string;
76
+ /** Notification message */
77
+ readonly message: string;
78
+ /** Notification timestamp */
79
+ readonly timestamp: number;
80
+ }
81
+
82
+ /**
83
+ * Geofence event payload
84
+ */
85
+ export interface PTRGeofenceEvent {
86
+ /** Event type (enter/exit/dwell) */
87
+ readonly eventType: PTRGeofenceEventType | string;
88
+ /** Geofence data */
89
+ readonly geofence?: PTRGeofence;
90
+ /** Optional notification */
91
+ readonly geofenceNotification?: PTRGeofenceNotification;
92
+ /** Event timestamp (iOS only) */
93
+ readonly timestamp?: number;
94
+ }
95
+
96
+ /**
97
+ * Map command response payload
98
+ */
99
+ export interface PTRMapCommandResponse {
100
+ /** Command type that was executed */
101
+ readonly command: string;
102
+ /** Site external identifier (for site commands) */
103
+ readonly siteExternalIdentifier?: string;
104
+ /** Error message if command failed */
105
+ readonly error?: string;
106
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Type definitions for the Pointr SDK
3
+ * @module types
4
+ */
5
+
6
+ // Export configuration types
7
+ export type { PTRConfiguration, PTRMapWidgetConfiguration, PTRStateCallback } from './config';
8
+
9
+ // Export event types
10
+ export type {
11
+ PTRPositionEvent,
12
+ PTRBuildingClickEvent,
13
+ PTRSiteClickEvent,
14
+ PTRGeofenceEvent,
15
+ PTRGeofence,
16
+ PTRGeofenceNotification,
17
+ PTRMapCommandResponse,
18
+ } from './events';
19
+
20
+ export { PTRGeofenceEventType } from './events';
21
+
22
+ // Export existing types
23
+ export type { PTRPoi, PTRPoiAttributes } from './PTRPoi';
24
+ export type { PTRPosition } from './PTRPosition';
25
+ export type { PTRWayfindingEvent } from './PTRWayfindingEvent';
26
+ export type {
27
+ PTRGeometry,
28
+ PTRGeoPoint,
29
+ PTRGeoLineString,
30
+ PTRGeoPolygon,
31
+ PTRGeoMultiPoint,
32
+ PTRGeoMultiLineString,
33
+ PTRGeoMultiPolygon,
34
+ PTRGeoCircle,
35
+ } from './PTRGeometry';
@@ -1,21 +0,0 @@
1
- {
2
- "java.configuration.updateBuildConfiguration": "disabled",
3
- "java.compile.nullAnalysis.mode": "automatic",
4
- "cSpell.words": [
5
- "androidx",
6
- "Autoresizing",
7
- "datamanager",
8
- "deeplink",
9
- "EDIP",
10
- "nativecore",
11
- "nonnull",
12
- "Parcelable",
13
- "Pathfinding",
14
- "pathmanager",
15
- "pointrlabs",
16
- "Subview",
17
- "uimanager",
18
- "viewmodels",
19
- "wayfinding"
20
- ]
21
- }
@@ -1,2 +0,0 @@
1
- BUNDLE_PATH: "vendor/bundle"
2
- BUNDLE_FORCE_RUBY_PLATFORM: 1
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: '@react-native',
4
- };
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- arrowParens: 'avoid',
3
- singleQuote: true,
4
- trailingComma: 'all',
5
- };
@@ -1 +0,0 @@
1
- {}
@@ -1,323 +0,0 @@
1
- import React, { useRef, useEffect, useState } from 'react';
2
- import {
3
- requireNativeComponent,
4
- findNodeHandle,
5
- Button,
6
- View,
7
- ScrollView,
8
- NativeSyntheticEvent,
9
- NativeModules,
10
- NativeEventEmitter
11
- } from 'react-native';
12
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
13
- import {
14
- getPois,
15
- showMapWidget,
16
- PTRSiteCommand,
17
- PTRBuildingCommand,
18
- PTRLevelCommand,
19
- PTRPoiCommand,
20
- PTRPathCommand,
21
- PTRStaticPathCommand,
22
- PTRMarkMyCarLevelCommand,
23
- PTRMarkMyCarSiteCommand,
24
- PTRShowMyCarSiteCommand,
25
- PTRStartAndFocusCommand,
26
- type PTRPoi,
27
- type PTRWayfindingEvent,
28
- } from 'react-native-pointr';
29
-
30
- interface PTRMapWidgetProps {
31
- style?: any;
32
- onMapWidgetDidEndLoading?: (event: NativeSyntheticEvent<any>) => void;
33
- onWayfindingEvent?: (event: NativeSyntheticEvent<PTRWayfindingEvent>) => void;
34
- }
35
- const PTRMapWidget = requireNativeComponent<PTRMapWidgetProps>('PTRMapWidget');
36
-
37
- // Create event emitter for Pointr events
38
- const PTREventEmitter = new NativeEventEmitter(NativeModules.PTRNativePointrLibrary);
39
-
40
- function App(): React.JSX.Element {
41
- const ref = useRef<any>(null);
42
- const [isInitialized, setIsInitialized] = useState(false);
43
- const insets = useSafeAreaInsets();
44
-
45
- // Initialize Pointr library when component mounts
46
- useEffect(() => {
47
- // Use setTimeout to defer initialization to next tick, preventing blocking
48
- const timer = setTimeout(() => {
49
- try {
50
- console.log('Initializing Pointr library...');
51
-
52
- // Initialize the Pointr library
53
- NativeModules.PTRNativePointrLibrary.initialize(
54
- "1ee58e56-fc35-4ec4-b32e-5d49e65fb52d",
55
- "af5d9431-56a3-46a9-ae0a-65d9757528d1",
56
- "https://sample-app-v9.pointr.cloud",
57
- 0
58
- );
59
-
60
- // Start the Pointr SDK
61
- NativeModules.PTRNativePointrLibrary.start((state: string) => {
62
- console.log(`Pointr state: ${state}`);
63
- setIsInitialized(true);
64
- });
65
-
66
- } catch (error) {
67
- console.error('Error initializing Pointr:', error);
68
- setIsInitialized(true); // Set to true anyway to prevent blocking UI
69
- }
70
- }, 100);
71
-
72
- return () => clearTimeout(timer);
73
- }, []);
74
-
75
- // Set up geofence event listener
76
- useEffect(() => {
77
- if (!isInitialized) return;
78
- // Subscribe to OnGeofenceEvent
79
- const geofenceSubscription = PTREventEmitter.addListener(
80
- 'OnGeofenceEvent',
81
- (geofenceEvent) => {
82
- console.log('=== Geofence Event Received ===');
83
- // Log the event type
84
- console.log(`Event Type: ${geofenceEvent.eventType}`);
85
-
86
- // Log timestamp if available (iOS only)
87
- if (geofenceEvent.timestamp) {
88
- console.log(`Timestamp: ${new Date(geofenceEvent.timestamp).toISOString()}`);
89
- }
90
-
91
- // Log geofence information
92
- if (geofenceEvent.geofence) {
93
- console.log('Geofence Information:');
94
- console.log(` - ID: ${geofenceEvent.geofence.id}`);
95
- console.log(` - External ID: ${geofenceEvent.geofence.externalId}`);
96
- console.log(` - Name: ${geofenceEvent.geofence.name}`);
97
- console.log(` - Type: ${geofenceEvent.geofence.geofenceType}`);
98
- console.log(` - Location: ${geofenceEvent.geofence.position.latitude}, ${geofenceEvent.geofence.position.longitude}`);
99
- }
100
-
101
- // Log notification information if available
102
- if (geofenceEvent.geofenceNotification) {
103
- console.log('Notification:');
104
- console.log(` - ID: ${geofenceEvent.geofenceNotification.id}`);
105
- console.log(` - Message: ${geofenceEvent.geofenceNotification.message}`);
106
- console.log(` - Timestamp: ${geofenceEvent.geofenceNotification.timestamp}`);
107
- }
108
-
109
- console.log('================================');
110
- }
111
- );
112
-
113
- const positionSubscription = PTREventEmitter.addListener("OnPositionManagerCalculatedLocation", (location) => {
114
- // console.log("Calculated Location: ", location);
115
- });
116
-
117
- // Clean up the subscription when component unmounts
118
- return () => {
119
- geofenceSubscription.remove();
120
- positionSubscription.remove();
121
- };
122
- }, [isInitialized]);
123
-
124
- const handleWayfindingEvent = (event: NativeSyntheticEvent<PTRWayfindingEvent>) => {
125
- const wayfindingEvent = event.nativeEvent;
126
-
127
- // Determine event type name
128
- let eventTypeName: string;
129
- switch (wayfindingEvent.type) {
130
- case -1:
131
- eventTypeName = 'Cancelled';
132
- break;
133
- case 0:
134
- eventTypeName = 'Started';
135
- break;
136
- case 1:
137
- eventTypeName = 'Ended';
138
- break;
139
- default:
140
- eventTypeName = 'Unknown';
141
- }
142
-
143
- console.log('=== Wayfinding Event ===');
144
- console.log(`Event Type: ${eventTypeName} (${wayfindingEvent.type})`);
145
- console.log('Destination POI:');
146
- console.log(` - Name: ${wayfindingEvent.poi.name}`);
147
- console.log(` - Identifier: ${wayfindingEvent.poi.identifier}`);
148
- console.log(` - External ID: ${wayfindingEvent.poi.externalIdentifier}`);
149
- console.log(` - Type Code: ${wayfindingEvent.poi.typeCode}`);
150
- console.log(` - Position: lat ${wayfindingEvent.poi.position.lat}, lon ${wayfindingEvent.poi.position.lon}, level ${wayfindingEvent.poi.position.lvl}`);
151
- console.log('========================');
152
- };
153
-
154
- const handleMapWidgetDidEndLoading = (event: NativeSyntheticEvent<any>) => {
155
- const ptrCommandResponse = event.nativeEvent;
156
- if (ptrCommandResponse.command === "site") {
157
- console.log("Map did end loading:", ptrCommandResponse.command, ptrCommandResponse.siteExternalIdentifier, ptrCommandResponse.error);
158
-
159
- getPois(ptrCommandResponse.siteExternalIdentifier)
160
- .then((pois: PTRPoi[]) => {
161
- console.log(`POIs fetched: ${pois.length} items`);
162
- // Example: Log first POI details
163
- if (pois.length > 0) {
164
- const firstPoi = pois[0];
165
- console.log('First POI:', {
166
- name: firstPoi.name,
167
- identifier: firstPoi.identifier,
168
- typeCode: firstPoi.typeCode,
169
- position: firstPoi.position,
170
- });
171
- }
172
- })
173
- .catch((error) => {
174
- console.error("Error fetching POIs:", error);
175
- });
176
- } else {
177
- console.log("Map did end loading with unknown parameters:", ptrCommandResponse);
178
- }
179
- };
180
-
181
- const showSite = () => {
182
- const reactTag = findNodeHandle(ref.current);
183
- if (reactTag) {
184
- let command = new PTRSiteCommand("workplace-portland");
185
- showMapWidget(reactTag, command);
186
- } else {
187
- console.error("Failed to find node handle for ref");
188
- }
189
- };
190
-
191
- const showBuilding = () => {
192
- const reactTag = findNodeHandle(ref.current);
193
- if (reactTag) {
194
- let command = new PTRBuildingCommand("workplace-portland", "office-east");
195
- showMapWidget(reactTag, command);
196
- } else {
197
- console.error("Failed to find node handle for ref");
198
- }
199
- };
200
-
201
- const showLevel = () => {
202
- const reactTag = findNodeHandle(ref.current);
203
- if (reactTag) {
204
- let command = new PTRLevelCommand("workplace-portland", "office-east", 2);
205
- showMapWidget(reactTag, command);
206
- } else {
207
- console.error("Failed to find node handle for ref");
208
- }
209
- };
210
-
211
- const showPoi = () => {
212
- const reactTag = findNodeHandle(ref.current);
213
- if (reactTag) {
214
- let command = new PTRPoiCommand("workplace-portland", "Lobby");
215
- showMapWidget(reactTag, command);
216
- } else {
217
- console.error("Failed to find node handle for ref");
218
- }
219
- };
220
-
221
- const showPath = () => {
222
- const reactTag = findNodeHandle(ref.current);
223
- if (reactTag) {
224
- let command = new PTRPathCommand("workplace-portland", "Lobby");
225
- showMapWidget(reactTag, command);
226
- } else {
227
- console.error("Failed to find node handle for ref");
228
- }
229
- };
230
-
231
- const showStaticPath = () => {
232
- const reactTag = findNodeHandle(ref.current);
233
- if (reactTag) {
234
- let command = new PTRStaticPathCommand("workplace-portland", "Accessories", "Lobby");
235
- showMapWidget(reactTag, command);
236
- } else {
237
- console.error("Failed to find node handle for ref");
238
- }
239
- };
240
-
241
- const markMyCarLevel = () => {
242
- const reactTag = findNodeHandle(ref.current);
243
- if (reactTag) {
244
- let command = new PTRMarkMyCarLevelCommand("workplace-portland", "office-east", 1, true);
245
- showMapWidget(reactTag, command);
246
- } else {
247
- console.error("Failed to find node handle for ref");
248
- }
249
- };
250
-
251
- const markMyCarSite = () => {
252
- const reactTag = findNodeHandle(ref.current);
253
- if (reactTag) {
254
- let command = new PTRMarkMyCarSiteCommand("workplace-portland", true);
255
- showMapWidget(reactTag, command);
256
- } else {
257
- console.error("Failed to find node handle for ref");
258
- }
259
- };
260
-
261
- const showMyCarSite = () => {
262
- const reactTag = findNodeHandle(ref.current);
263
- if (reactTag) {
264
- let command = new PTRShowMyCarSiteCommand("workplace-portland", true);
265
- showMapWidget(reactTag, command);
266
- } else {
267
- console.error("Failed to find node handle for ref");
268
- }
269
- };
270
-
271
- const startAndFocusSite = () => {
272
- const reactTag = findNodeHandle(ref.current);
273
- if (reactTag) {
274
- const siteCommand = new PTRSiteCommand("workplace-portland");
275
- const command = new PTRStartAndFocusCommand(
276
- "1ee58e56-fc35-4ec4-b32e-5d49e65fb52d",
277
- "af5d9431-56a3-46a9-ae0a-65d9757528d1",
278
- "https://sample-app-v9.pointr.cloud",
279
- 0,
280
- siteCommand
281
- );
282
- showMapWidget(reactTag, command);
283
- } else {
284
- console.error("Failed to find node handle for ref");
285
- }
286
- };
287
-
288
- return (
289
- <View style={{ flex: 1 }}>
290
- <View style={{ flex: 1, paddingTop: insets.top, paddingLeft: insets.left, paddingRight: insets.right }}>
291
- <ScrollView style={{ flex: 1 }} contentContainerStyle={{ padding: 16 }}>
292
- <Button title="Show Site" onPress={showSite} />
293
- <View style={{ height: 12 }} />
294
- <Button title="Show Building" onPress={showBuilding} />
295
- <View style={{ height: 12 }} />
296
- <Button title="Show Level" onPress={showLevel} />
297
- <View style={{ height: 12 }} />
298
- <Button title="Show POI" onPress={showPoi} />
299
- <View style={{ height: 12 }} />
300
- <Button title="Show Path" onPress={showPath} />
301
- <View style={{ height: 12 }} />
302
- <Button title="Show Static Path" onPress={showStaticPath} />
303
- <View style={{ height: 12 }} />
304
- <Button title="Mark My Car Level" onPress={markMyCarLevel} />
305
- <View style={{ height: 12 }} />
306
- <Button title="Mark My Car Site" onPress={markMyCarSite} />
307
- <View style={{ height: 12 }} />
308
- <Button title="Show My Car Site" onPress={showMyCarSite} />
309
- <View style={{ height: 12 }} />
310
- <Button title="Start & Focus Site" onPress={startAndFocusSite} />
311
- </ScrollView>
312
- </View>
313
- <PTRMapWidget
314
- ref={ref}
315
- style={{ flex: 4 }}
316
- onMapWidgetDidEndLoading={handleMapWidgetDidEndLoading}
317
- onWayfindingEvent={handleWayfindingEvent}
318
- />
319
- </View>
320
- );
321
- }
322
-
323
- export default App;