react-native-pointr 9.1.0 → 9.3.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/API_REFERENCE.md +887 -0
- package/CHANGELOG.md +35 -0
- package/EXTENDING.md +419 -0
- package/README.md +221 -117
- package/WAYFINDING_EVENTS.md +243 -0
- package/android/build.gradle +3 -16
- package/android/src/main/java/com/pointr/PTRCoreExtensions.kt +126 -0
- package/android/src/main/java/com/pointr/PTRMapWidgetCommandType.kt +3 -1
- package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +160 -11
- package/android/src/main/java/com/pointr/PointrModule.kt +106 -3
- package/example/pointr_rn_demo/.bundle/config +2 -0
- package/example/pointr_rn_demo/.eslintrc.js +4 -0
- package/example/pointr_rn_demo/.prettierrc.js +5 -0
- package/example/pointr_rn_demo/.watchmanconfig +1 -0
- package/example/pointr_rn_demo/App.tsx +323 -0
- package/example/pointr_rn_demo/Gemfile +16 -0
- package/example/pointr_rn_demo/Gemfile.lock +111 -0
- package/example/pointr_rn_demo/README.md +188 -0
- package/example/pointr_rn_demo/__tests__/App.test.tsx +13 -0
- package/example/pointr_rn_demo/android/app/build.gradle +119 -0
- package/example/pointr_rn_demo/android/app/debug.keystore +0 -0
- package/example/pointr_rn_demo/android/app/proguard-rules.pro +10 -0
- package/example/pointr_rn_demo/android/app/src/main/AndroidManifest.xml +27 -0
- package/example/pointr_rn_demo/android/app/src/main/java/com/pointr_rn_demo/MainActivity.kt +22 -0
- package/example/pointr_rn_demo/android/app/src/main/java/com/pointr_rn_demo/MainApplication.kt +27 -0
- package/example/pointr_rn_demo/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/values/strings.xml +3 -0
- package/example/pointr_rn_demo/android/app/src/main/res/values/styles.xml +9 -0
- package/example/pointr_rn_demo/android/build.gradle +32 -0
- package/example/pointr_rn_demo/android/gradle.properties +44 -0
- package/example/pointr_rn_demo/android/settings.gradle +6 -0
- package/example/pointr_rn_demo/app.json +4 -0
- package/example/pointr_rn_demo/babel.config.js +3 -0
- package/example/pointr_rn_demo/index.js +16 -0
- package/example/pointr_rn_demo/ios/.xcode.env +11 -0
- package/example/pointr_rn_demo/ios/Podfile +40 -0
- package/example/pointr_rn_demo/ios/Podfile.lock +2767 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/AppDelegate.swift +48 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/Images.xcassets/Contents.json +6 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/Info.plist +63 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/LaunchScreen.storyboard +47 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/PrivacyInfo.xcprivacy +37 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo.xcodeproj/project.pbxproj +496 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo.xcodeproj/xcshareddata/xcschemes/pointr_rn_demo.xcscheme +88 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo.xcworkspace/contents.xcworkspacedata +10 -0
- package/example/pointr_rn_demo/jest.config.js +3 -0
- package/example/pointr_rn_demo/metro.config.js +22 -0
- package/example/pointr_rn_demo/package-lock.json +11747 -0
- package/example/pointr_rn_demo/package.json +46 -0
- package/example/pointr_rn_demo/prepare-demo-distribution.sh +103 -0
- package/example/pointr_rn_demo/tsconfig.json +5 -0
- package/ios/PTRMapWidgetContainerView.swift +59 -7
- package/ios/PTRMapWidgetManager-Bridging.m +65 -1
- package/ios/PTRMapWidgetManager.swift +185 -144
- package/ios/PTRNativeLibrary-Bridging.m +4 -0
- package/ios/PTRNativeLibrary.swift +244 -18
- package/package.json +16 -2
- package/prepare-distribution.sh +84 -0
- package/react-native-pointr.podspec +1 -1
- package/src/PTRCommand.ts +34 -1
- package/src/PTRMapWidgetUtils.ts +105 -5
- package/src/PTRPoiManager.ts +20 -0
- package/src/index.tsx +40 -1
- package/src/types/PTRGeometry.ts +70 -0
- package/src/types/PTRPoi.ts +49 -0
- package/src/types/PTRPosition.ts +22 -0
- package/src/types/PTRWayfindingEvent.ts +18 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Foundation
|
|
2
1
|
import PointrKit
|
|
3
2
|
import React
|
|
4
3
|
|
|
@@ -6,6 +5,7 @@ import React
|
|
|
6
5
|
func onPositionManagerCalculatedLocation(location: [String: Any])
|
|
7
6
|
func onBuildingClicked(_ building: [String: Any])
|
|
8
7
|
func onSiteClicked(_ site: [String: Any])
|
|
8
|
+
func onGeofenceEvent(_ geofenceEvent: [String: Any])
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
@objc(PTRNativePointrLibrary)
|
|
@@ -22,25 +22,28 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
22
22
|
var ptrMapWidget: PTRMapWidgetViewController? = nil
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
static var configuration: Dictionary<String,Any>? = nil
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return mapWidgetConfiguration
|
|
30
|
-
}
|
|
31
|
-
let mirror = Mirror(reflecting: mapWidgetConfiguration)
|
|
32
|
-
for attr in mirror.children {
|
|
33
|
-
guard let key = attr.label else {
|
|
34
|
-
continue
|
|
25
|
+
static var configuration: Dictionary<String,Any>? = nil {
|
|
26
|
+
didSet {
|
|
27
|
+
guard let configuration else {
|
|
28
|
+
return
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
let mirror = Mirror(reflecting: mapWidgetConfiguration)
|
|
31
|
+
for attr in mirror.children {
|
|
32
|
+
guard let key = attr.label else {
|
|
33
|
+
continue
|
|
34
|
+
}
|
|
35
|
+
// only set boolean values
|
|
36
|
+
guard let value = configuration[key] as? Bool, attr.value is Bool else {
|
|
37
|
+
continue
|
|
38
|
+
}
|
|
39
|
+
mapWidgetConfiguration.setValue(value, forKey: key)
|
|
39
40
|
}
|
|
40
|
-
mapWidgetConfiguration.setValue(value, forKey: key)
|
|
41
41
|
}
|
|
42
|
-
return mapWidgetConfiguration
|
|
43
42
|
}
|
|
43
|
+
|
|
44
|
+
@objc public
|
|
45
|
+
static var mapWidgetConfiguration: PTRMapWidgetConfiguration = PTRMapWidgetConfiguration.defaultConfiguration()
|
|
46
|
+
|
|
44
47
|
private var dispatchGroupSiteManager = [DispatchGroup]()
|
|
45
48
|
var rootViewController: UIViewController? = nil
|
|
46
49
|
var isRouteFooterViewEnabled = true
|
|
@@ -48,6 +51,11 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
48
51
|
override init() {
|
|
49
52
|
super.init()
|
|
50
53
|
self.eventManagerDelegate = self
|
|
54
|
+
guard let permissionManager = Pointr.shared.permissionManager else {
|
|
55
|
+
print("EDIP - Pointr permission manager not available")
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
permissionManager.delegate = self
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
override static func requiresMainQueueSetup() -> Bool {
|
|
@@ -55,7 +63,7 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
override func supportedEvents() -> [String]! {
|
|
58
|
-
return ["OnPositionManagerCalculatedLocation", "OnBuildingClicked", "OnSiteClicked"]
|
|
66
|
+
return ["OnPositionManagerCalculatedLocation", "OnBuildingClicked", "OnSiteClicked", "OnGeofenceEvent"]
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
override func startObserving() {
|
|
@@ -98,6 +106,48 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
98
106
|
return dictionary
|
|
99
107
|
}
|
|
100
108
|
|
|
109
|
+
// Converts a PTRGeofenceEvent object to [String: Any] dictionary by extracting its explicit fields
|
|
110
|
+
func convertGeofenceEventToDict(_ geofenceEvent: PTRGeofenceEvent) -> [String: Any] {
|
|
111
|
+
var dictionary = [String: Any]()
|
|
112
|
+
|
|
113
|
+
// Event type
|
|
114
|
+
let typeString = geofenceEvent.type == .enter ? "enter" : "exit"
|
|
115
|
+
dictionary.updateValue(typeString, forKey: "eventType")
|
|
116
|
+
|
|
117
|
+
// Event date (convert to milliseconds)
|
|
118
|
+
dictionary.updateValue(geofenceEvent.date.timeIntervalSince1970 * 1000, forKey: "timestamp")
|
|
119
|
+
|
|
120
|
+
// Geofence information
|
|
121
|
+
var geofenceDict = [String: Any]()
|
|
122
|
+
geofenceDict.updateValue(geofenceEvent.geofence.identifier, forKey: "id")
|
|
123
|
+
geofenceDict.updateValue(geofenceEvent.geofence.externalIdentifier, forKey: "externalId")
|
|
124
|
+
geofenceDict.updateValue(geofenceEvent.geofence.name, forKey: "name")
|
|
125
|
+
|
|
126
|
+
// Geofence type
|
|
127
|
+
let geofenceTypeString = geofenceEvent.geofence.type == .beacon ? "beacon" : "gps"
|
|
128
|
+
geofenceDict.updateValue(geofenceTypeString, forKey: "geofenceType")
|
|
129
|
+
|
|
130
|
+
// Geofence position (if available)
|
|
131
|
+
var positionDict = [String: Any]()
|
|
132
|
+
let position = geofenceEvent.geofence.position
|
|
133
|
+
positionDict.updateValue(position.coordinate.latitude, forKey: "latitude")
|
|
134
|
+
positionDict.updateValue(position.coordinate.longitude, forKey: "longitude")
|
|
135
|
+
geofenceDict.updateValue(positionDict, forKey: "position")
|
|
136
|
+
|
|
137
|
+
dictionary.updateValue(geofenceDict, forKey: "geofence")
|
|
138
|
+
|
|
139
|
+
// Notification information (if available)
|
|
140
|
+
if let notification = geofenceEvent.notification {
|
|
141
|
+
var notificationDict = [String: Any]()
|
|
142
|
+
notificationDict.updateValue(notification.identifier, forKey: "id")
|
|
143
|
+
notificationDict.updateValue(notification.message, forKey: "message")
|
|
144
|
+
notificationDict.updateValue(notification.date.timeIntervalSince1970 * 1000, forKey: "timestamp")
|
|
145
|
+
dictionary.updateValue(notificationDict, forKey: "geofenceNotification")
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return dictionary
|
|
149
|
+
}
|
|
150
|
+
|
|
101
151
|
func getAnimationTypeFromInt(value: Int) -> PTRMapAnimationType {
|
|
102
152
|
switch value {
|
|
103
153
|
case 0:
|
|
@@ -146,7 +196,6 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
146
196
|
baseUrl: String,
|
|
147
197
|
logLevel: Int) {
|
|
148
198
|
guard let presentedViewController = RCTPresentedViewController() else { return }
|
|
149
|
-
Pointr.shared.permissionManager?.delegate = self
|
|
150
199
|
self.rootViewController = presentedViewController
|
|
151
200
|
PTRNativeLibrary.params.mode = PointrDebugMode()
|
|
152
201
|
PTRNativeLibrary.params.loggerLevel = PTRLoggerLevel.init(rawValue: Int32(logLevel)) ?? .error
|
|
@@ -169,6 +218,7 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
169
218
|
dispatchGroup.wait()
|
|
170
219
|
if Pointr.shared.state == .running {
|
|
171
220
|
Pointr.shared.positioningManager?.addListener(self)
|
|
221
|
+
Pointr.shared.geofenceManager?.addListener(self)
|
|
172
222
|
}
|
|
173
223
|
callback([getPointrStateStringFromPointrState(state: Pointr.shared.state)])
|
|
174
224
|
}
|
|
@@ -176,6 +226,7 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
176
226
|
|
|
177
227
|
@objc func stop() {
|
|
178
228
|
Pointr.shared.positioningManager?.removeListener(self)
|
|
229
|
+
Pointr.shared.geofenceManager?.removeListener(self)
|
|
179
230
|
Pointr.shared.stop()
|
|
180
231
|
}
|
|
181
232
|
|
|
@@ -258,6 +309,23 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
258
309
|
callback([])
|
|
259
310
|
}
|
|
260
311
|
|
|
312
|
+
@objc(getPois:resolver:rejecter:)
|
|
313
|
+
func getPois(_ siteId: String,
|
|
314
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
315
|
+
rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
316
|
+
|
|
317
|
+
// Ensure Pointr SDK is initialized
|
|
318
|
+
guard let site = Pointr.shared.siteManager?.site(withExternalIdentifier: siteId) else {
|
|
319
|
+
reject("ERROR", "Site not found: \(siteId)", nil)
|
|
320
|
+
return
|
|
321
|
+
}
|
|
322
|
+
// Get all POIs for the site
|
|
323
|
+
let pois = Pointr.shared.poiManager?.pois(for: site)?.getPoiList() ?? []
|
|
324
|
+
// Convert POIs to dictionary format (aligned with Kotlin implementation)
|
|
325
|
+
let poisData = pois.map { return $0.dict }
|
|
326
|
+
resolve(poisData)
|
|
327
|
+
}
|
|
328
|
+
|
|
261
329
|
// MARK: - Event Manager Delegate
|
|
262
330
|
|
|
263
331
|
func onPositionManagerCalculatedLocation(location: [String : Any]) {
|
|
@@ -265,6 +333,11 @@ class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
|
265
333
|
sendEvent(withName: "OnPositionManagerCalculatedLocation", body: location)
|
|
266
334
|
}
|
|
267
335
|
|
|
336
|
+
func onGeofenceEvent(_ geofenceEvent: [String: Any]) {
|
|
337
|
+
guard hasListeners else { return }
|
|
338
|
+
sendEvent(withName: "OnGeofenceEvent", body: geofenceEvent)
|
|
339
|
+
}
|
|
340
|
+
|
|
268
341
|
func onBuildingClicked(_ building: [String : Any]) {
|
|
269
342
|
guard hasListeners else { return }
|
|
270
343
|
sendEvent(withName: "OnBuildingClicked", body: building)
|
|
@@ -283,6 +356,12 @@ extension PTRNativeLibrary: PTRPositioningManagerDelegate {
|
|
|
283
356
|
}
|
|
284
357
|
}
|
|
285
358
|
|
|
359
|
+
extension PTRNativeLibrary: PTRGeofenceManagerDelegate {
|
|
360
|
+
func onGeofenceManagerGeofenceEvent(_ event: PTRGeofenceEvent) {
|
|
361
|
+
eventManagerDelegate?.onGeofenceEvent(self.convertGeofenceEventToDict(event))
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
286
365
|
// MARK: - PTRExitButtonEventsListener
|
|
287
366
|
extension PTRNativeLibrary: PTRExitButtonEventsListener {
|
|
288
367
|
func exitButtonDidTap() {
|
|
@@ -324,14 +403,161 @@ extension PTRNativeLibrary: PTRSiteManagerDelegate {
|
|
|
324
403
|
// MARK: - PTRPermissionManagerDelegate
|
|
325
404
|
extension PTRNativeLibrary: PTRPermissionManagerDelegate {
|
|
326
405
|
public func permissionManagerShouldRequestLocationAuthorizationPermission() -> Bool {
|
|
406
|
+
Plogv("Should request location permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
327
407
|
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
328
408
|
}
|
|
329
409
|
|
|
330
410
|
public func permissionManagerShouldRequestBluetoothServicesPermission() -> Bool {
|
|
411
|
+
Plogv("Should request bluetooth permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
331
412
|
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
332
413
|
}
|
|
333
414
|
|
|
334
415
|
public func permissionManagerShouldRequestUserNotificationAuthorizationPermission() -> Bool {
|
|
416
|
+
Plogv("Should request notification permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
335
417
|
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
336
418
|
}
|
|
419
|
+
|
|
420
|
+
public func permissionManagerShouldRequestCoreMotionAuthorizationPermission(_ permissionManager: any PTRPermissionManagerInterface) -> Bool {
|
|
421
|
+
Plogv("Should request core motion permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
422
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
func permissionManagerShouldRequestLocationAuthorizationPermissionForWhenInUse(_ permissionManager: any PTRPermissionManagerInterface) -> Bool {
|
|
426
|
+
Plogv("Should request location when in use permission: \(PTRNativeLibrary.shouldRequestPermissionsAtStartup)")
|
|
427
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
extension PTRFeature {
|
|
432
|
+
public var dict: [String: Any] {
|
|
433
|
+
var result: [String: Any] = [
|
|
434
|
+
"identifier": identifier,
|
|
435
|
+
"externalIdentifier": externalIdentifier,
|
|
436
|
+
"typeCode": typeCode,
|
|
437
|
+
"name": name
|
|
438
|
+
]
|
|
439
|
+
if let geometry = geometry {
|
|
440
|
+
result["geometry"] = geometry.dict
|
|
441
|
+
}
|
|
442
|
+
result["attributes"] = attributes.toDict
|
|
443
|
+
result["position"] = position.dict
|
|
444
|
+
return result
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
extension PTRPosition {
|
|
449
|
+
public var dict: [String: Any] {
|
|
450
|
+
var result: [String: Any] = [
|
|
451
|
+
"lat": coordinate.latitude,
|
|
452
|
+
"lon": coordinate.longitude,
|
|
453
|
+
"isValid": isValid(),
|
|
454
|
+
]
|
|
455
|
+
if let site = site {
|
|
456
|
+
result["sid"] = site.identifier
|
|
457
|
+
}
|
|
458
|
+
if let building = building {
|
|
459
|
+
result["bid"] = building.identifier
|
|
460
|
+
}
|
|
461
|
+
if let level = level {
|
|
462
|
+
result["lvl"] = level.index
|
|
463
|
+
}
|
|
464
|
+
return result
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
private extension Dictionary where Key == String, Value == Any {
|
|
469
|
+
var toDict: [String: Any] {
|
|
470
|
+
var result: [String: Any] = [:]
|
|
471
|
+
for (key, value) in self {
|
|
472
|
+
switch value {
|
|
473
|
+
case let v as Int: result[key] = v
|
|
474
|
+
case let v as Double: result[key] = v
|
|
475
|
+
case let v as Bool: result[key] = v
|
|
476
|
+
case let v as String: result[key] = v
|
|
477
|
+
case let v as [Any]:
|
|
478
|
+
result[key] = v.map { ($0 as? [String: Any])?.toDict ?? $0 }
|
|
479
|
+
case let v as [String: Any]:
|
|
480
|
+
result[key] = v.toDict
|
|
481
|
+
default: break
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return result
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
extension PTRGeometry {
|
|
489
|
+
|
|
490
|
+
public var typeName : String {
|
|
491
|
+
switch (type) {
|
|
492
|
+
case .circle:
|
|
493
|
+
return "Circle"
|
|
494
|
+
case .multiLineString:
|
|
495
|
+
return "MultiLineString"
|
|
496
|
+
case .multiPoint:
|
|
497
|
+
return "MultiPoint"
|
|
498
|
+
case .multiPolygon:
|
|
499
|
+
return "MultiPolygon"
|
|
500
|
+
case .point:
|
|
501
|
+
return "Point"
|
|
502
|
+
case .polygon:
|
|
503
|
+
return "Polygon"
|
|
504
|
+
case .lineString:
|
|
505
|
+
return "LineString"
|
|
506
|
+
case .geometryCollection:
|
|
507
|
+
return "GeometryCollection"
|
|
508
|
+
@unknown default:
|
|
509
|
+
return "Unknown"
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
public var dict: [String: Any] {
|
|
515
|
+
// Default type name
|
|
516
|
+
var result: [String: Any] = ["type": typeName]
|
|
517
|
+
|
|
518
|
+
// Handle known geometry subclasses from PointrKit
|
|
519
|
+
switch self {
|
|
520
|
+
case let point as PTRGeoPoint:
|
|
521
|
+
// Single coordinate
|
|
522
|
+
let coord = point.coordinate
|
|
523
|
+
result["lat"] = coord.latitude
|
|
524
|
+
result["lon"] = coord.longitude
|
|
525
|
+
|
|
526
|
+
case let line as PTRGeoLineString:
|
|
527
|
+
// Array of coordinates
|
|
528
|
+
let coords = line.points.map { $0.dict }
|
|
529
|
+
result["points"] = coords
|
|
530
|
+
|
|
531
|
+
case let polygon as PTRGeoPolygon:
|
|
532
|
+
// Outer ring + inner rings (holes) if any
|
|
533
|
+
let exterior = polygon.outer.map { $0.dict }
|
|
534
|
+
let holes = polygon.inners.map { ring in
|
|
535
|
+
ring.map { $0.dict }
|
|
536
|
+
}
|
|
537
|
+
result["outer"] = exterior
|
|
538
|
+
result["inners"] = holes
|
|
539
|
+
|
|
540
|
+
case let multiPoint as PTRGeoMultiPoint:
|
|
541
|
+
let coords = multiPoint.points.map { $0.dict }
|
|
542
|
+
result["points"] = coords
|
|
543
|
+
|
|
544
|
+
case let multiLine as PTRGeoMultiLineString:
|
|
545
|
+
let lines = multiLine.lineStrings.map { line in
|
|
546
|
+
line.dict
|
|
547
|
+
}
|
|
548
|
+
result["lineStrings"] = lines
|
|
549
|
+
|
|
550
|
+
case let multiPolygon as PTRGeoMultiPolygon:
|
|
551
|
+
let polys = multiPolygon.polygons.map { poly in
|
|
552
|
+
poly.dict
|
|
553
|
+
}
|
|
554
|
+
result["polygons"] = polys
|
|
555
|
+
|
|
556
|
+
default:
|
|
557
|
+
// Unknown geometry type; keep only the type string
|
|
558
|
+
break
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return result
|
|
562
|
+
}
|
|
337
563
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-pointr",
|
|
3
|
-
"version": "9.1
|
|
3
|
+
"version": "9.3.1",
|
|
4
4
|
"description": "Pointr React-Native Module",
|
|
5
5
|
"main": "src/index",
|
|
6
6
|
"author": " <> ()",
|
|
@@ -10,5 +10,19 @@
|
|
|
10
10
|
"type": "module-legacy",
|
|
11
11
|
"languages": "kotlin-swift",
|
|
12
12
|
"version": "0.41.0"
|
|
13
|
+
},
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"react-native": ">=0.64.0",
|
|
16
|
+
"react": ">=17.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/node": "^24.10.1",
|
|
20
|
+
"react-native": "^0.82.1"
|
|
21
|
+
},
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prepare-dist": "chmod +x prepare-distribution.sh && ./prepare-distribution.sh"
|
|
13
27
|
}
|
|
14
|
-
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Script to prepare react-native-pointr package for distribution
|
|
4
|
+
# This script cleans build artifacts, removes git history, and creates a compressed archive
|
|
5
|
+
|
|
6
|
+
set -e # Exit on error
|
|
7
|
+
|
|
8
|
+
PACKAGE_NAME="react-native-pointr"
|
|
9
|
+
VERSION=$(grep -o '"version": "[^"]*"' package.json | head -1 | sed 's/"version": "\(.*\)"/\1/')
|
|
10
|
+
OUTPUT_NAME="${PACKAGE_NAME}-${VERSION}.zip"
|
|
11
|
+
TEMP_DIR="${PACKAGE_NAME}_temp"
|
|
12
|
+
|
|
13
|
+
echo "🧹 Starting package cleanup and preparation..."
|
|
14
|
+
echo "📌 Package version: ${VERSION}"
|
|
15
|
+
|
|
16
|
+
# Create a temporary copy of the package
|
|
17
|
+
echo "📦 Creating temporary copy..."
|
|
18
|
+
rsync -a --exclude=".git" \
|
|
19
|
+
--exclude="node_modules" \
|
|
20
|
+
--exclude="example" \
|
|
21
|
+
--exclude=".DS_Store" \
|
|
22
|
+
--exclude="*.log" \
|
|
23
|
+
--exclude="prepare-distribution.sh" \
|
|
24
|
+
./ "../${TEMP_DIR}/"
|
|
25
|
+
|
|
26
|
+
cd "../${TEMP_DIR}"
|
|
27
|
+
|
|
28
|
+
# Clean Android build artifacts
|
|
29
|
+
echo "🤖 Cleaning Android build artifacts..."
|
|
30
|
+
if [ -d "android/build" ]; then
|
|
31
|
+
rm -rf android/build
|
|
32
|
+
fi
|
|
33
|
+
if [ -d "android/.gradle" ]; then
|
|
34
|
+
rm -rf android/.gradle
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# Clean iOS build artifacts
|
|
38
|
+
echo "🍎 Cleaning iOS build artifacts..."
|
|
39
|
+
if [ -d "ios/build" ]; then
|
|
40
|
+
rm -rf ios/build
|
|
41
|
+
fi
|
|
42
|
+
if [ -d "ios/Pods" ]; then
|
|
43
|
+
rm -rf ios/Pods
|
|
44
|
+
fi
|
|
45
|
+
if [ -f "ios/Podfile.lock" ]; then
|
|
46
|
+
rm -f ios/Podfile.lock
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Remove common development files
|
|
50
|
+
echo "🗑️ Removing development files..."
|
|
51
|
+
rm -rf .git
|
|
52
|
+
rm -rf .gitignore
|
|
53
|
+
rm -rf .github
|
|
54
|
+
rm -rf node_modules
|
|
55
|
+
rm -rf .vscode
|
|
56
|
+
rm -rf .idea
|
|
57
|
+
rm -f .DS_Store
|
|
58
|
+
rm -f *.log
|
|
59
|
+
rm -f npm-debug.log*
|
|
60
|
+
rm -f yarn-debug.log*
|
|
61
|
+
rm -f yarn-error.log*
|
|
62
|
+
rm -f package-lock.json
|
|
63
|
+
rm -f yarn.lock
|
|
64
|
+
|
|
65
|
+
# Create the zip archive
|
|
66
|
+
echo "📦 Creating compressed archive..."
|
|
67
|
+
cd ..
|
|
68
|
+
zip -r "${OUTPUT_NAME}" "${TEMP_DIR}" -x "*.DS_Store" -q
|
|
69
|
+
|
|
70
|
+
# Create dist directory if it doesn't exist
|
|
71
|
+
mkdir -p "${PACKAGE_NAME}/dist"
|
|
72
|
+
|
|
73
|
+
# Move the archive to dist directory
|
|
74
|
+
mv "${OUTPUT_NAME}" "${PACKAGE_NAME}/dist/"
|
|
75
|
+
|
|
76
|
+
# Clean up temporary directory
|
|
77
|
+
echo "🧼 Cleaning up temporary files..."
|
|
78
|
+
rm -rf "${TEMP_DIR}"
|
|
79
|
+
|
|
80
|
+
cd "${PACKAGE_NAME}"
|
|
81
|
+
|
|
82
|
+
echo "✅ Distribution package created successfully!"
|
|
83
|
+
echo "📦 Output file: ${OUTPUT_NAME}"
|
|
84
|
+
echo "📍 Location: $(pwd)/dist/${OUTPUT_NAME}"
|
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
|
-
s.dependency 'PointrKit', '9.
|
|
19
|
+
s.dependency 'PointrKit', '9.3.0'
|
|
20
20
|
|
|
21
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/src/PTRCommand.ts
CHANGED
|
@@ -8,9 +8,11 @@ export enum PTRCommandType {
|
|
|
8
8
|
POI = "poi",
|
|
9
9
|
PATH = "path",
|
|
10
10
|
STATIC_PATH = "staticPath",
|
|
11
|
+
STATIC_WAYFINDING = "staticWayfinding",
|
|
11
12
|
MARK_MY_CAR_LEVEL = "markMyCarForLevel",
|
|
12
13
|
MARK_MY_CAR_SITE = "markMyCarForSite",
|
|
13
|
-
SHOW_MY_CAR_SITE = "showMyCarForSite"
|
|
14
|
+
SHOW_MY_CAR_SITE = "showMyCarForSite",
|
|
15
|
+
START_AND_FOCUS = "startAndFocus"
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* Base class for all Pointr SDK commands
|
|
@@ -81,6 +83,18 @@ export class PTRStaticPathCommand extends PTRCommand {
|
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Command to show static wayfinding using PTRMapWidgetStaticWayfindingAction
|
|
88
|
+
* @param site - the site that has the POIs
|
|
89
|
+
* @param sourcePoi - the source POI location to start the path from
|
|
90
|
+
* @param destinationPoi - the destination POI location to end the path at
|
|
91
|
+
*/
|
|
92
|
+
export class PTRStaticWayfindingCommand extends PTRCommand {
|
|
93
|
+
constructor(public site: string, public sourcePoi: string, public destinationPoi: string) {
|
|
94
|
+
super(PTRCommandType.STATIC_WAYFINDING);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
84
98
|
/**
|
|
85
99
|
* Command to show mark my car details
|
|
86
100
|
* @param site - the site to show mark my car details
|
|
@@ -117,4 +131,23 @@ export class PTRShowMyCarSiteCommand extends PTRCommand {
|
|
|
117
131
|
constructor(public site: string, public shouldShowPopup: boolean = true, public animationType: number = 1) {
|
|
118
132
|
super(PTRCommandType.SHOW_MY_CAR_SITE);
|
|
119
133
|
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Command to start the SDK and focus on a location using an existing PTR command
|
|
138
|
+
* This command is not a PTRCommand itself, but wraps SDK initialization with a focus command
|
|
139
|
+
* @param clientId - the client ID for SDK initialization
|
|
140
|
+
* @param licenseKey - the license key for SDK initialization
|
|
141
|
+
* @param baseUrl - the base URL for SDK initialization
|
|
142
|
+
* @param logLevel - the log level for SDK initialization
|
|
143
|
+
* @param command - the PTR command to execute after SDK initialization (PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, or PTRPoiCommand)
|
|
144
|
+
*/
|
|
145
|
+
export class PTRStartAndFocusCommand {
|
|
146
|
+
constructor(
|
|
147
|
+
public clientId: string,
|
|
148
|
+
public licenseKey: string,
|
|
149
|
+
public baseUrl: string,
|
|
150
|
+
public logLevel: number = 4,
|
|
151
|
+
public command: PTRSiteCommand | PTRBuildingCommand | PTRLevelCommand | PTRPoiCommand
|
|
152
|
+
) {}
|
|
120
153
|
}
|
package/src/PTRMapWidgetUtils.ts
CHANGED
|
@@ -1,13 +1,104 @@
|
|
|
1
1
|
import { UIManager } from 'react-native';
|
|
2
|
-
import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRCommand, PTRCommandType, PTRMarkMyCarLevelCommand, PTRMarkMyCarSiteCommand, PTRShowMyCarSiteCommand } from 'react-native-pointr/src/PTRCommand';
|
|
2
|
+
import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRStaticWayfindingCommand, PTRCommand, PTRCommandType, PTRMarkMyCarLevelCommand, PTRMarkMyCarSiteCommand, PTRShowMyCarSiteCommand, PTRStartAndFocusCommand } from 'react-native-pointr/src/PTRCommand';
|
|
3
|
+
/**
|
|
4
|
+
* Handle PTRStartAndFocusCommand specifically
|
|
5
|
+
* @param reactTag view tag of the map widget
|
|
6
|
+
* @param startAndFocusCommand the start and focus command
|
|
7
|
+
*/
|
|
8
|
+
const handleStartAndFocusCommand = (reactTag: number, startAndFocusCommand: PTRStartAndFocusCommand) => {
|
|
9
|
+
const innerCommand = startAndFocusCommand.command;
|
|
10
|
+
console.info('Handling PTRStartAndFocusCommand with type:', innerCommand.type);
|
|
11
|
+
// Build arguments based on the inner command type
|
|
12
|
+
let args: any[];
|
|
13
|
+
console.info('Inner command details:', innerCommand);
|
|
14
|
+
|
|
15
|
+
switch (innerCommand.type) {
|
|
16
|
+
case PTRCommandType.SITE: {
|
|
17
|
+
const siteCommand = innerCommand as PTRSiteCommand;
|
|
18
|
+
args = [
|
|
19
|
+
startAndFocusCommand.clientId,
|
|
20
|
+
startAndFocusCommand.licenseKey,
|
|
21
|
+
startAndFocusCommand.baseUrl,
|
|
22
|
+
startAndFocusCommand.logLevel,
|
|
23
|
+
innerCommand.type,
|
|
24
|
+
siteCommand.site,
|
|
25
|
+
"",
|
|
26
|
+
0
|
|
27
|
+
];
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case PTRCommandType.BUILDING: {
|
|
31
|
+
const buildingCommand = innerCommand as PTRBuildingCommand;
|
|
32
|
+
args = [
|
|
33
|
+
startAndFocusCommand.clientId,
|
|
34
|
+
startAndFocusCommand.licenseKey,
|
|
35
|
+
startAndFocusCommand.baseUrl,
|
|
36
|
+
startAndFocusCommand.logLevel,
|
|
37
|
+
innerCommand.type,
|
|
38
|
+
buildingCommand.site,
|
|
39
|
+
buildingCommand.building,
|
|
40
|
+
0
|
|
41
|
+
];
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case PTRCommandType.LEVEL: {
|
|
45
|
+
const levelCommand = innerCommand as PTRLevelCommand;
|
|
46
|
+
args = [
|
|
47
|
+
startAndFocusCommand.clientId,
|
|
48
|
+
startAndFocusCommand.licenseKey,
|
|
49
|
+
startAndFocusCommand.baseUrl,
|
|
50
|
+
startAndFocusCommand.logLevel,
|
|
51
|
+
innerCommand.type,
|
|
52
|
+
levelCommand.site,
|
|
53
|
+
levelCommand.building,
|
|
54
|
+
levelCommand.level
|
|
55
|
+
];
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case PTRCommandType.POI: {
|
|
59
|
+
const poiCommand = innerCommand as PTRPoiCommand;
|
|
60
|
+
args = [
|
|
61
|
+
startAndFocusCommand.clientId,
|
|
62
|
+
startAndFocusCommand.licenseKey,
|
|
63
|
+
startAndFocusCommand.baseUrl,
|
|
64
|
+
startAndFocusCommand.logLevel,
|
|
65
|
+
innerCommand.type,
|
|
66
|
+
poiCommand.site,
|
|
67
|
+
poiCommand.poi,
|
|
68
|
+
0
|
|
69
|
+
];
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
console.error('Unsupported command type in PTRStartAndFocusCommand:', innerCommand.type);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
console.info('Dispatching startAndFocus with args:', args);
|
|
77
|
+
UIManager.dispatchViewManagerCommand(
|
|
78
|
+
reactTag,
|
|
79
|
+
'startAndFocus',
|
|
80
|
+
args,
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
3
84
|
/**
|
|
4
85
|
* Show the map widget with the given command
|
|
5
86
|
* @param reactTag view tag of the map widget
|
|
6
|
-
* @param ptrCommand command to show the map widget
|
|
87
|
+
* @param ptrCommand command to show the map widget (PTRCommand or PTRStartAndFocusCommand)
|
|
7
88
|
*/
|
|
8
|
-
export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
9
|
-
|
|
10
|
-
|
|
89
|
+
export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand | PTRStartAndFocusCommand) => {
|
|
90
|
+
// Check if it's a PTRStartAndFocusCommand (which doesn't have a 'type' property)
|
|
91
|
+
if ('command' in ptrCommand) {
|
|
92
|
+
const startAndFocusCommand = ptrCommand as PTRStartAndFocusCommand;
|
|
93
|
+
console.log(`Showing map widget with start and focus command: ${startAndFocusCommand.command.type} and reactTag: ${reactTag}`);
|
|
94
|
+
handleStartAndFocusCommand(reactTag, startAndFocusCommand);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Handle regular PTRCommand
|
|
99
|
+
const command = ptrCommand as PTRCommand;
|
|
100
|
+
console.log(`Showing map widget with command: ${command.type} and reactTag: ${reactTag}`);
|
|
101
|
+
switch (command.type) {
|
|
11
102
|
case PTRCommandType.SITE: {
|
|
12
103
|
const siteCommand = ptrCommand as PTRSiteCommand;
|
|
13
104
|
UIManager.dispatchViewManagerCommand(
|
|
@@ -62,6 +153,15 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
62
153
|
);
|
|
63
154
|
break;
|
|
64
155
|
}
|
|
156
|
+
case PTRCommandType.STATIC_WAYFINDING: {
|
|
157
|
+
const staticWayfindingCommand = ptrCommand as PTRStaticWayfindingCommand;
|
|
158
|
+
UIManager.dispatchViewManagerCommand(
|
|
159
|
+
reactTag,
|
|
160
|
+
'staticWayfinding',
|
|
161
|
+
[staticWayfindingCommand.site, staticWayfindingCommand.sourcePoi, staticWayfindingCommand.destinationPoi],
|
|
162
|
+
);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
65
165
|
case PTRCommandType.MARK_MY_CAR_LEVEL: {
|
|
66
166
|
const markMyCarCommand = ptrCommand as PTRMarkMyCarLevelCommand;
|
|
67
167
|
UIManager.dispatchViewManagerCommand(
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
import { PTRPoi } from './types/PTRPoi';
|
|
3
|
+
|
|
4
|
+
const { PTRNativePointrLibrary } = NativeModules;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get all Points of Interest (POIs) for a specific site
|
|
8
|
+
* @param siteId - The external identifier of the site
|
|
9
|
+
* @returns Promise that resolves with an array of POIs
|
|
10
|
+
* @throws Error if the site is not found or if the operation fails
|
|
11
|
+
*/
|
|
12
|
+
export async function getPois(siteId: string): Promise<PTRPoi[]> {
|
|
13
|
+
try {
|
|
14
|
+
const pois = await PTRNativePointrLibrary.getPois(siteId);
|
|
15
|
+
return pois as PTRPoi[];
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error('Failed to get POIs:', error);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|