react-native-pointr 8.16.0 → 9.1.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.
- package/CHANGELOG.md +8 -0
- package/android/build.gradle +20 -11
- package/android/gradle.properties +3 -3
- package/android/src/main/AndroidManifestNew.xml +2 -9
- package/android/src/main/java/com/pointr/PTRMapWidgetCommandType.kt +1 -3
- package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +178 -394
- package/android/src/main/java/com/pointr/PointrModule.kt +36 -177
- package/ios/PTRMapWidgetContainerView.swift +247 -0
- package/ios/PTRMapWidgetManager-Bridging.m +59 -0
- package/ios/PTRMapWidgetManager.swift +242 -0
- package/ios/PTRNativeLibrary-Bridging.m +34 -0
- package/ios/PTRNativeLibrary.swift +337 -0
- package/ios/react-native-pointr-Bridging-Header.h +5 -0
- package/package.json +1 -1
- package/react-native-pointr.podspec +1 -1
- package/src/PTRCommand.ts +5 -4
- package/src/PTRMapWidgetUtils.ts +13 -13
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
- package/android/src/main/AndroidManifest.xml +0 -12
- package/android/src/main/java/com/pointr/PointrMapWidgetActivity.kt +0 -485
- package/android/src/main/res/layout/pointr_map_widget_activity_layout.xml +0 -16
- package/ios/PTRMapWidgetContainerView.h +0 -19
- package/ios/PTRMapWidgetContainerView.m +0 -281
- package/ios/PTRMapWidgetManager.m +0 -256
- package/ios/PTRNativeLibrary.h +0 -11
- package/ios/PTRNativeLibrary.m +0 -159
- package/ios/PointrApp.swift +0 -636
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import React
|
|
3
|
+
import PointrKit
|
|
4
|
+
|
|
5
|
+
@objc(PTRMapWidgetManager)
|
|
6
|
+
public class PTRMapWidgetManager: RCTViewManager {
|
|
7
|
+
|
|
8
|
+
override public static func requiresMainQueueSetup() -> Bool {
|
|
9
|
+
return true
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
override public func view() -> UIView! {
|
|
13
|
+
return PTRMapWidgetContainerView()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
override public static func moduleName() -> String! {
|
|
17
|
+
return "PTRMapWidget"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@objc func site(_ reactTag: NSNumber, siteExternalIdentifier: String) {
|
|
22
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
23
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
24
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
DispatchQueue.main.async {
|
|
29
|
+
|
|
30
|
+
let siteLocation = PTRMapWidgetSiteLocation(siteIdentifier: siteExternalIdentifier, isExternalIdentifiers: true)
|
|
31
|
+
let action = PTRMapWidgetMapFocusAction(location: siteLocation)
|
|
32
|
+
action.completion = { error in
|
|
33
|
+
let ptrCommand: [String: Any] = [
|
|
34
|
+
"command": "site",
|
|
35
|
+
"siteExternalIdentifier": siteExternalIdentifier,
|
|
36
|
+
"error": error?.errorCode ?? ""
|
|
37
|
+
]
|
|
38
|
+
ptrMapWidgetContainerView.ptrMapWidgetDidEndLoading(withParameters: ptrCommand)
|
|
39
|
+
}
|
|
40
|
+
let mapWidget = ptrMapWidgetContainerView.getMapWidget(action)
|
|
41
|
+
print("calling show site method of mapWidget")
|
|
42
|
+
ptrMapWidgetContainerView.present(mapWidget)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@objc func building(_ reactTag: NSNumber, siteExternalIdentifier: String, buildingExternalIdentifier: String) {
|
|
48
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
49
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
50
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
DispatchQueue.main.async {
|
|
55
|
+
let action = PTRMapWidgetMapFocusAction(location: PTRMapWidgetBuildingLocation(siteIdentifier: siteExternalIdentifier, buildingIdentifier: buildingExternalIdentifier, isExternalIdentifiers: true))
|
|
56
|
+
action.completion = { error in
|
|
57
|
+
let ptrCommand: [String: Any] = [
|
|
58
|
+
"command": "building",
|
|
59
|
+
"siteExternalIdentifier": siteExternalIdentifier,
|
|
60
|
+
"buildingExternalIdentifier": buildingExternalIdentifier,
|
|
61
|
+
"error": error?.errorCode ?? ""
|
|
62
|
+
]
|
|
63
|
+
ptrMapWidgetContainerView.ptrMapWidgetDidEndLoading(withParameters: ptrCommand)
|
|
64
|
+
}
|
|
65
|
+
let mapWidget = ptrMapWidgetContainerView.getMapWidget(action)
|
|
66
|
+
print("calling show building method of mapWidget")
|
|
67
|
+
ptrMapWidgetContainerView.present(mapWidget)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@objc func level(_ reactTag: NSNumber, siteExternalIdentifier: String, buildingExternalIdentifier: String, levelIndex: Int) {
|
|
73
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
74
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
75
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
DispatchQueue.main.async {
|
|
80
|
+
let action = PTRMapWidgetMapFocusAction(location: PTRMapWidgetLevelLocation(siteIdentifier: siteExternalIdentifier, buildingIdentifier: buildingExternalIdentifier, levelIndex: levelIndex, isExternalIdentifiers: true))
|
|
81
|
+
action.completion = { error in
|
|
82
|
+
let ptrCommand: [String: Any] = [
|
|
83
|
+
"command": "level",
|
|
84
|
+
"siteExternalIdentifier": siteExternalIdentifier,
|
|
85
|
+
"buildingExternalIdentifier": buildingExternalIdentifier,
|
|
86
|
+
"levelIndex": levelIndex,
|
|
87
|
+
"error": error?.errorCode ?? ""
|
|
88
|
+
]
|
|
89
|
+
ptrMapWidgetContainerView.ptrMapWidgetDidEndLoading(withParameters: ptrCommand)
|
|
90
|
+
}
|
|
91
|
+
let mapWidget = ptrMapWidgetContainerView.getMapWidget(action)
|
|
92
|
+
print("calling show level method of mapWidget")
|
|
93
|
+
ptrMapWidgetContainerView.present(mapWidget)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@objc func poi(_ reactTag: NSNumber, siteExternalIdentifier: String, poiExternalIdentifier: String) {
|
|
99
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
100
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
101
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
DispatchQueue.main.async {
|
|
106
|
+
let action = PTRMapWidgetMapFocusAction(location: PTRMapWidgetPoiLocation(siteIdentifier: siteExternalIdentifier, poiIdentifier: poiExternalIdentifier, isExternalIdentifiers: true))
|
|
107
|
+
action.completion = { error in
|
|
108
|
+
let ptrCommand: [String: Any] = [
|
|
109
|
+
"command": "poi",
|
|
110
|
+
"siteExternalIdentifier": siteExternalIdentifier,
|
|
111
|
+
"poiExternalIdentifier": poiExternalIdentifier,
|
|
112
|
+
"error": error?.errorCode ?? ""
|
|
113
|
+
]
|
|
114
|
+
ptrMapWidgetContainerView.ptrMapWidgetDidEndLoading(withParameters: ptrCommand)
|
|
115
|
+
}
|
|
116
|
+
let mapWidget = ptrMapWidgetContainerView.getMapWidget(action)
|
|
117
|
+
print("calling show poi method of mapWidget")
|
|
118
|
+
ptrMapWidgetContainerView.present(mapWidget)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@objc func path(_ reactTag: NSNumber, siteExternalIdentifier: String, toPoiExternalIdentifier: String) {
|
|
124
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
125
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
126
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
DispatchQueue.main.async {
|
|
131
|
+
let action = PTRMapWidgetWayfindingAction(poiDestination: PTRMapWidgetPoiLocation(siteIdentifier: siteExternalIdentifier, poiIdentifier: toPoiExternalIdentifier, isExternalIdentifiers: true))
|
|
132
|
+
action.completion = { error in
|
|
133
|
+
let ptrCommand: [String: Any] = [
|
|
134
|
+
"command": "path",
|
|
135
|
+
"siteExternalIdentifier": siteExternalIdentifier,
|
|
136
|
+
"poiExternalIdentifier": toPoiExternalIdentifier,
|
|
137
|
+
"error": error?.errorCode ?? ""
|
|
138
|
+
]
|
|
139
|
+
ptrMapWidgetContainerView.ptrMapWidgetDidEndLoading(withParameters: ptrCommand)
|
|
140
|
+
}
|
|
141
|
+
let mapWidget = ptrMapWidgetContainerView.getMapWidget(action)
|
|
142
|
+
print("calling show path method of mapWidget")
|
|
143
|
+
ptrMapWidgetContainerView.present(mapWidget)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@objc func staticPath(_ reactTag: NSNumber, siteExternalIdentifier: String, fromPoiExternalIdentifier: String, toPoiExternalIdentifier: String) {
|
|
149
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
150
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
151
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
DispatchQueue.global(qos: .default).async {
|
|
156
|
+
ptrMapWidgetContainerView.showStaticPath(siteExternalIdentifier,
|
|
157
|
+
fromPoiExternalIdentifier: fromPoiExternalIdentifier,
|
|
158
|
+
toPoiExternalIdentifier: toPoiExternalIdentifier)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@objc func markMyCarForLevel(_ reactTag: NSNumber, siteExternalIdentifier: String, buildingExternalIdentifier: String, levelIndex: Int, shouldShowPopup: Bool, animationType: Int) {
|
|
164
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
165
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
166
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
167
|
+
return
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
DispatchQueue.main.async {
|
|
171
|
+
let action = PTRMapWidgetMarkMyCarAction(levelLocation: PTRMapWidgetLevelLocation(siteIdentifier: siteExternalIdentifier, buildingIdentifier: buildingExternalIdentifier, levelIndex: levelIndex, isExternalIdentifiers: true), shouldShowPopup: shouldShowPopup)
|
|
172
|
+
action.completion = { error in
|
|
173
|
+
let ptrCommand: [String: Any] = [
|
|
174
|
+
"command": "markMyCarForLevel",
|
|
175
|
+
"siteExternalIdentifier": siteExternalIdentifier,
|
|
176
|
+
"buildingExternalIdentifier": buildingExternalIdentifier,
|
|
177
|
+
"levelIndex": levelIndex,
|
|
178
|
+
"shouldShowPopup": shouldShowPopup,
|
|
179
|
+
"animationType": animationType,
|
|
180
|
+
"error": error?.errorCode ?? ""
|
|
181
|
+
]
|
|
182
|
+
ptrMapWidgetContainerView.ptrMapWidgetDidEndLoading(withParameters: ptrCommand)
|
|
183
|
+
}
|
|
184
|
+
let mapWidget = ptrMapWidgetContainerView.getMapWidget(action)
|
|
185
|
+
print("calling show mark my car method of mapWidget")
|
|
186
|
+
ptrMapWidgetContainerView.present(mapWidget)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@objc func markMyCarForSite(_ reactTag: NSNumber, siteExternalIdentifier: String, shouldShowPopup: Bool, animationType: Int) {
|
|
192
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
193
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
194
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
DispatchQueue.main.async {
|
|
199
|
+
let action = PTRMapWidgetMarkMyCarAction(siteLocation: PTRMapWidgetSiteLocation(siteIdentifier: siteExternalIdentifier, isExternalIdentifiers: true), shouldShowPopup: shouldShowPopup)
|
|
200
|
+
action.completion = { error in
|
|
201
|
+
let ptrCommand: [String: Any] = [
|
|
202
|
+
"command": "markMyCarForSite",
|
|
203
|
+
"siteExternalIdentifier": siteExternalIdentifier,
|
|
204
|
+
"shouldShowPopup": shouldShowPopup,
|
|
205
|
+
"animationType": animationType,
|
|
206
|
+
"error": error?.errorCode ?? ""
|
|
207
|
+
]
|
|
208
|
+
ptrMapWidgetContainerView.ptrMapWidgetDidEndLoading(withParameters: ptrCommand)
|
|
209
|
+
}
|
|
210
|
+
let mapWidget = ptrMapWidgetContainerView.getMapWidget(action)
|
|
211
|
+
print("calling show mark my car method of mapWidget")
|
|
212
|
+
ptrMapWidgetContainerView.present(mapWidget)
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@objc func myCarForSite(_ reactTag: NSNumber, siteExternalIdentifier: String, animationType: Int) {
|
|
218
|
+
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
|
|
219
|
+
guard let ptrMapWidgetContainerView = uiManager?.view(forReactTag: reactTag) as? PTRMapWidgetContainerView else {
|
|
220
|
+
print("Cannot find PTRMapWidgetContainerView with tag #\(reactTag)")
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
DispatchQueue.main.async {
|
|
225
|
+
let action = PTRMapWidgetShowMyCarAction(location: PTRMapWidgetSiteLocation(siteIdentifier: siteExternalIdentifier, isExternalIdentifiers: true))
|
|
226
|
+
action.completion = { error in
|
|
227
|
+
let ptrCommand: [String: Any] = [
|
|
228
|
+
"command": "myCarForSite",
|
|
229
|
+
"siteExternalIdentifier": siteExternalIdentifier,
|
|
230
|
+
"animationType": animationType,
|
|
231
|
+
"error": error?.errorCode ?? ""
|
|
232
|
+
]
|
|
233
|
+
ptrMapWidgetContainerView.ptrMapWidgetDidEndLoading(withParameters: ptrCommand)
|
|
234
|
+
}
|
|
235
|
+
let mapWidget = ptrMapWidgetContainerView.getMapWidget(action)
|
|
236
|
+
print("calling show mark my car method of mapWidget")
|
|
237
|
+
ptrMapWidgetContainerView.present(mapWidget)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PTRNativeLibrary-Bridging.m
|
|
3
|
+
//
|
|
4
|
+
// This file provides Objective-C wrappers for Swift classes to make them accessible from React Native
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
#import <React/RCTBridgeModule.h>
|
|
8
|
+
#import <React/RCTEventEmitter.h>
|
|
9
|
+
|
|
10
|
+
@interface RCT_EXTERN_MODULE(PTRNativePointrLibrary, RCTEventEmitter)
|
|
11
|
+
|
|
12
|
+
// Event emitter methods
|
|
13
|
+
RCT_EXTERN_METHOD(supportedEvents)
|
|
14
|
+
RCT_EXTERN_METHOD(startObserving)
|
|
15
|
+
RCT_EXTERN_METHOD(stopObserving)
|
|
16
|
+
|
|
17
|
+
// Core methods
|
|
18
|
+
RCT_EXTERN_METHOD(shouldRequestPermissionsAtStartup:(BOOL)shouldRequestPermissionsAtStartup)
|
|
19
|
+
|
|
20
|
+
RCT_EXTERN_METHOD(initialize:(NSString *)clientIdentifier licenseKey:(NSString *)licenseKey baseUrl:(NSString *)baseUrl logLevel:(int)logLevel)
|
|
21
|
+
|
|
22
|
+
RCT_EXTERN_METHOD(start:(RCTResponseSenderBlock)callback)
|
|
23
|
+
|
|
24
|
+
RCT_EXTERN_METHOD(stop)
|
|
25
|
+
|
|
26
|
+
RCT_EXTERN_METHOD(getCurrentLocation:(RCTResponseSenderBlock)callback)
|
|
27
|
+
|
|
28
|
+
RCT_EXTERN_METHOD(setPointrMapWidgetConfiguration:(NSString *)string)
|
|
29
|
+
|
|
30
|
+
RCT_EXTERN_METHOD(requestPermissions)
|
|
31
|
+
|
|
32
|
+
RCT_EXTERN_METHOD(isMyCarMarked:(RCTResponseSenderBlock)callback)
|
|
33
|
+
|
|
34
|
+
@end
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import PointrKit
|
|
3
|
+
import React
|
|
4
|
+
|
|
5
|
+
@objc public protocol PTREventManagerDelegate {
|
|
6
|
+
func onPositionManagerCalculatedLocation(location: [String: Any])
|
|
7
|
+
func onBuildingClicked(_ building: [String: Any])
|
|
8
|
+
func onSiteClicked(_ site: [String: Any])
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc(PTRNativePointrLibrary)
|
|
12
|
+
class PTRNativeLibrary: RCTEventEmitter, PTREventManagerDelegate {
|
|
13
|
+
|
|
14
|
+
private var hasListeners = false
|
|
15
|
+
|
|
16
|
+
// PointrApp functionality moved here
|
|
17
|
+
@objc public weak var eventManagerDelegate: PTREventManagerDelegate?
|
|
18
|
+
@objc public static var shouldRequestPermissionsAtStartup: Bool = true
|
|
19
|
+
@objc public static let params = PTRParams()
|
|
20
|
+
|
|
21
|
+
let dispatchGroup = DispatchGroup()
|
|
22
|
+
var ptrMapWidget: PTRMapWidgetViewController? = nil
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
static var configuration: Dictionary<String,Any>? = nil
|
|
26
|
+
static var mapWidgetConfiguration: PTRMapWidgetConfiguration {
|
|
27
|
+
let mapWidgetConfiguration = PTRMapWidgetConfiguration.defaultConfiguration()
|
|
28
|
+
guard let configuration else {
|
|
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
|
|
35
|
+
}
|
|
36
|
+
// only set boolean values
|
|
37
|
+
guard let value = configuration[key] as? Bool, attr.value is Bool else {
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
mapWidgetConfiguration.setValue(value, forKey: key)
|
|
41
|
+
}
|
|
42
|
+
return mapWidgetConfiguration
|
|
43
|
+
}
|
|
44
|
+
private var dispatchGroupSiteManager = [DispatchGroup]()
|
|
45
|
+
var rootViewController: UIViewController? = nil
|
|
46
|
+
var isRouteFooterViewEnabled = true
|
|
47
|
+
|
|
48
|
+
override init() {
|
|
49
|
+
super.init()
|
|
50
|
+
self.eventManagerDelegate = self
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
override static func requiresMainQueueSetup() -> Bool {
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
override func supportedEvents() -> [String]! {
|
|
58
|
+
return ["OnPositionManagerCalculatedLocation", "OnBuildingClicked", "OnSiteClicked"]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override func startObserving() {
|
|
62
|
+
hasListeners = true
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override func stopObserving() {
|
|
66
|
+
hasListeners = false
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// MARK: - Utility Methods (from PointrApp)
|
|
70
|
+
|
|
71
|
+
func covertToDictionary(_ location: PTRCalculatedPosition) -> [String: Any] {
|
|
72
|
+
var dictionary = [String: Any]()
|
|
73
|
+
if let siteInternalIdentifier = location.site?.internalIdentifier {
|
|
74
|
+
dictionary.updateValue(siteInternalIdentifier, forKey: "siteInternalIdentifier")
|
|
75
|
+
}
|
|
76
|
+
if let buildingInternalIdentifier = location.building?.internalIdentifier {
|
|
77
|
+
dictionary.updateValue(buildingInternalIdentifier, forKey: "buildingInternalIdentifier")
|
|
78
|
+
}
|
|
79
|
+
if let siteExternalIdentifier = location.site?.externalIdentifier {
|
|
80
|
+
dictionary.updateValue(siteExternalIdentifier, forKey: "siteExternalIdentifier")
|
|
81
|
+
}
|
|
82
|
+
if let buildingExternalIdentifier = location.building?.externalIdentifier {
|
|
83
|
+
dictionary.updateValue(buildingExternalIdentifier, forKey: "buildingExternalIdentifier")
|
|
84
|
+
}
|
|
85
|
+
if let levelIndex = location.level?.index {
|
|
86
|
+
dictionary.updateValue(levelIndex, forKey: "levelIndex")
|
|
87
|
+
}
|
|
88
|
+
if location.coordinate.latitude != CLLocationDegrees(PTRPositioningTypes.invalidFloat()) && location.coordinate.longitude != CLLocationDegrees(PTRPositioningTypes.invalidFloat()) {
|
|
89
|
+
dictionary.updateValue(location.coordinate.latitude, forKey: "latitude")
|
|
90
|
+
dictionary.updateValue(location.coordinate.longitude, forKey: "longitude")
|
|
91
|
+
}
|
|
92
|
+
if location.accuracy != Double(PTRPositioningTypes.invalidFloat()) {
|
|
93
|
+
dictionary.updateValue(location.accuracy, forKey: "accuracy")
|
|
94
|
+
}
|
|
95
|
+
if (location.headingAccuracyClass == .high) {
|
|
96
|
+
dictionary.updateValue(location.heading, forKey: "heading")
|
|
97
|
+
}
|
|
98
|
+
return dictionary
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
func getAnimationTypeFromInt(value: Int) -> PTRMapAnimationType {
|
|
102
|
+
switch value {
|
|
103
|
+
case 0:
|
|
104
|
+
return .none
|
|
105
|
+
case 1:
|
|
106
|
+
return .standard
|
|
107
|
+
case 2:
|
|
108
|
+
return .flyOver
|
|
109
|
+
default:
|
|
110
|
+
return .none
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
func getErrorStringFromMapWidgetError(error: PTRMapWidgetError?) -> String? {
|
|
115
|
+
guard let error = error else {
|
|
116
|
+
return nil
|
|
117
|
+
}
|
|
118
|
+
return "\(error.errorCode ?? "")"
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
func getPointrStateStringFromPointrState(state: PointrState) -> String {
|
|
122
|
+
switch (state) {
|
|
123
|
+
case .running:
|
|
124
|
+
return "running"
|
|
125
|
+
case .failedRegistration:
|
|
126
|
+
return "failed registration"
|
|
127
|
+
case .failedValidation:
|
|
128
|
+
return "failed validation"
|
|
129
|
+
case .failedInvalidDeepLinkUrl:
|
|
130
|
+
return "failed invalid deep link url"
|
|
131
|
+
case .failedNoInternet:
|
|
132
|
+
return "failed no internet"
|
|
133
|
+
default:
|
|
134
|
+
return "off"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// MARK: - Core Methods
|
|
139
|
+
|
|
140
|
+
@objc func shouldRequestPermissionsAtStartup(_ shouldRequestPermissionsAtStartup: Bool) {
|
|
141
|
+
PTRNativeLibrary.shouldRequestPermissionsAtStartup = shouldRequestPermissionsAtStartup
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@objc func initialize(_ clientIdentifier: String,
|
|
145
|
+
licenseKey: String,
|
|
146
|
+
baseUrl: String,
|
|
147
|
+
logLevel: Int) {
|
|
148
|
+
guard let presentedViewController = RCTPresentedViewController() else { return }
|
|
149
|
+
Pointr.shared.permissionManager?.delegate = self
|
|
150
|
+
self.rootViewController = presentedViewController
|
|
151
|
+
PTRNativeLibrary.params.mode = PointrDebugMode()
|
|
152
|
+
PTRNativeLibrary.params.loggerLevel = PTRLoggerLevel.init(rawValue: Int32(logLevel)) ?? .error
|
|
153
|
+
PTRNativeLibrary.params.licenseKey = licenseKey
|
|
154
|
+
PTRNativeLibrary.params.baseUrl = baseUrl
|
|
155
|
+
PTRNativeLibrary.params.clientIdentifier = clientIdentifier
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@objc func start(_ callback: @escaping RCTResponseSenderBlock) {
|
|
159
|
+
if Pointr.shared.state == .running {
|
|
160
|
+
callback(["Pointr is already running"])
|
|
161
|
+
} else {
|
|
162
|
+
let dispatchGroup = DispatchGroup()
|
|
163
|
+
dispatchGroup.enter()
|
|
164
|
+
Pointr.shared.start(with: PTRNativeLibrary.params) { state in
|
|
165
|
+
if (state == .running || state.rawValue <= 0) {
|
|
166
|
+
dispatchGroup.leave()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
dispatchGroup.wait()
|
|
170
|
+
if Pointr.shared.state == .running {
|
|
171
|
+
Pointr.shared.positioningManager?.addListener(self)
|
|
172
|
+
}
|
|
173
|
+
callback([getPointrStateStringFromPointrState(state: Pointr.shared.state)])
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@objc func stop() {
|
|
178
|
+
Pointr.shared.positioningManager?.removeListener(self)
|
|
179
|
+
Pointr.shared.stop()
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@objc func requestPermissions() {
|
|
183
|
+
guard let permissionManager = Pointr.shared.permissionManager else { return }
|
|
184
|
+
if (!permissionManager.hasLocationAuthorizationWhenInUseOrAlways) {
|
|
185
|
+
permissionManager.requestLocationAuthorizationPermissionForWhenInUse()
|
|
186
|
+
}
|
|
187
|
+
if #available(iOS 17.4, *) {
|
|
188
|
+
if (!permissionManager.hasCoreMotionAuthorization) {
|
|
189
|
+
permissionManager.requestCoreMotionAuthorizationPermission()
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// MARK: - Map Widget Methods
|
|
195
|
+
|
|
196
|
+
func initializeMapWidget() {
|
|
197
|
+
if ptrMapWidget == nil {
|
|
198
|
+
ptrMapWidget = PTRMapWidgetViewController(location: PTRMapWidgetSiteLocation(siteIdentifier: ""), configuration: PTRNativeLibrary.mapWidgetConfiguration)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
func presentMapWidgetIfNotPresented() {
|
|
203
|
+
guard let ptrMapWidget = ptrMapWidget,
|
|
204
|
+
let rootViewController = rootViewController else { return }
|
|
205
|
+
|
|
206
|
+
if ptrMapWidget.view.superview == nil {
|
|
207
|
+
rootViewController.view.addSubview(ptrMapWidget.view)
|
|
208
|
+
ptrMapWidget.view.translatesAutoresizingMaskIntoConstraints = false
|
|
209
|
+
NSLayoutConstraint.activate([
|
|
210
|
+
ptrMapWidget.view.topAnchor.constraint(equalTo: rootViewController.view.safeAreaLayoutGuide.topAnchor),
|
|
211
|
+
ptrMapWidget.view.leadingAnchor.constraint(equalTo: rootViewController.view.leadingAnchor),
|
|
212
|
+
ptrMapWidget.view.trailingAnchor.constraint(equalTo: rootViewController.view.trailingAnchor),
|
|
213
|
+
ptrMapWidget.view.bottomAnchor.constraint(equalTo: rootViewController.view.bottomAnchor)
|
|
214
|
+
])
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
@objc func getCurrentLocation(_ callback: @escaping RCTResponseSenderBlock) {
|
|
219
|
+
guard let positionManager = Pointr.shared.positioningManager else {
|
|
220
|
+
callback(["Position manager not available"])
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if let lastLocation = positionManager.lastValidCalculatedPosition {
|
|
225
|
+
let locationDict = covertToDictionary(lastLocation)
|
|
226
|
+
if let latitude = locationDict["latitude"] as? Double, latitude != -999999 {
|
|
227
|
+
callback([locationDict])
|
|
228
|
+
} else {
|
|
229
|
+
callback(["There is no location"])
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
callback(["There is no location"])
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@objc func setPointrMapWidgetConfiguration(_ string: String) {
|
|
237
|
+
guard let data = string.data(using: .utf8) else {
|
|
238
|
+
print("String does not have valid data")
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
do {
|
|
242
|
+
guard let jsonObject = try JSONSerialization.jsonObject(with: data) as? Dictionary<String,Any> else {
|
|
243
|
+
print("Bad json")
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
PTRNativeLibrary.configuration = jsonObject
|
|
247
|
+
} catch let error as NSError {
|
|
248
|
+
print("Error parsing json: \(string)\n\(error)")
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@objc func isMyCarMarked(_ callback: @escaping RCTResponseSenderBlock) {
|
|
253
|
+
let feature = Pointr.shared.getMyCarFeature()
|
|
254
|
+
if feature == nil {
|
|
255
|
+
callback(["No saved location"])
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
callback([])
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// MARK: - Event Manager Delegate
|
|
262
|
+
|
|
263
|
+
func onPositionManagerCalculatedLocation(location: [String : Any]) {
|
|
264
|
+
guard hasListeners else { return }
|
|
265
|
+
sendEvent(withName: "OnPositionManagerCalculatedLocation", body: location)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
func onBuildingClicked(_ building: [String : Any]) {
|
|
269
|
+
guard hasListeners else { return }
|
|
270
|
+
sendEvent(withName: "OnBuildingClicked", body: building)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
func onSiteClicked(_ site: [String : Any]) {
|
|
274
|
+
guard hasListeners else { return }
|
|
275
|
+
sendEvent(withName: "OnSiteClicked", body: site)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// MARK: - PTRPositionManagerDelegate
|
|
280
|
+
extension PTRNativeLibrary: PTRPositioningManagerDelegate {
|
|
281
|
+
func onPositioningManagerCalculatedPosition(_ calculatedPosition: PTRCalculatedPosition) {
|
|
282
|
+
eventManagerDelegate?.onPositionManagerCalculatedLocation(location: self.covertToDictionary(calculatedPosition))
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// MARK: - PTRExitButtonEventsListener
|
|
287
|
+
extension PTRNativeLibrary: PTRExitButtonEventsListener {
|
|
288
|
+
func exitButtonDidTap() {
|
|
289
|
+
self.ptrMapWidget?.view.removeFromSuperview()
|
|
290
|
+
self.ptrMapWidget = nil
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// MARK: - PTRMapEventsListener
|
|
295
|
+
extension PTRNativeLibrary: PTRMapEventsListener {
|
|
296
|
+
public func map(_ map: PTRMapViewController, didReceiveTapOnFeature feature: PTRFeature) {
|
|
297
|
+
// Handle feature tap if needed
|
|
298
|
+
if (feature.typeCode == "building-outline") {
|
|
299
|
+
eventManagerDelegate?.onBuildingClicked([
|
|
300
|
+
"internalIdentifier": feature.identifier,
|
|
301
|
+
"externalIdentifier": feature.externalIdentifier,
|
|
302
|
+
"title": feature.name
|
|
303
|
+
])
|
|
304
|
+
} else if (feature.typeCode == "site-outline") {
|
|
305
|
+
eventManagerDelegate?.onSiteClicked([
|
|
306
|
+
"internalIdentifier": feature.identifier,
|
|
307
|
+
"externalIdentifier": feature.externalIdentifier,
|
|
308
|
+
"title": feature.name
|
|
309
|
+
])
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// MARK: - PTRSiteManagerDelegate
|
|
315
|
+
extension PTRNativeLibrary: PTRSiteManagerDelegate {
|
|
316
|
+
public func onSiteManagerDataChanged() {
|
|
317
|
+
while(!dispatchGroupSiteManager.isEmpty) {
|
|
318
|
+
let dispatchGroup = dispatchGroupSiteManager.removeLast()
|
|
319
|
+
dispatchGroup.leave()
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// MARK: - PTRPermissionManagerDelegate
|
|
325
|
+
extension PTRNativeLibrary: PTRPermissionManagerDelegate {
|
|
326
|
+
public func permissionManagerShouldRequestLocationAuthorizationPermission() -> Bool {
|
|
327
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
public func permissionManagerShouldRequestBluetoothServicesPermission() -> Bool {
|
|
331
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
public func permissionManagerShouldRequestUserNotificationAuthorizationPermission() -> Bool {
|
|
335
|
+
return PTRNativeLibrary.shouldRequestPermissionsAtStartup
|
|
336
|
+
}
|
|
337
|
+
}
|
package/package.json
CHANGED
|
@@ -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', '
|
|
19
|
+
s.dependency 'PointrKit', '9.1.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
|
@@ -10,7 +10,7 @@ export enum PTRCommandType {
|
|
|
10
10
|
STATIC_PATH = "staticPath",
|
|
11
11
|
MARK_MY_CAR_LEVEL = "markMyCarForLevel",
|
|
12
12
|
MARK_MY_CAR_SITE = "markMyCarForSite",
|
|
13
|
-
|
|
13
|
+
SHOW_MY_CAR_SITE = "showMyCarForSite"
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Base class for all Pointr SDK commands
|
|
@@ -110,10 +110,11 @@ export class PTRMarkMyCarSiteCommand extends PTRCommand {
|
|
|
110
110
|
/**
|
|
111
111
|
* Command to show my car details
|
|
112
112
|
* @param site - the site to show my car details
|
|
113
|
+
* @param shouldShowPopup - flag to show popup or not
|
|
113
114
|
* @param animationType - animation type to show map loading
|
|
114
115
|
*/
|
|
115
|
-
export class
|
|
116
|
-
constructor(public site: string, public animationType: number = 1) {
|
|
117
|
-
super(PTRCommandType.
|
|
116
|
+
export class PTRShowMyCarSiteCommand extends PTRCommand {
|
|
117
|
+
constructor(public site: string, public shouldShowPopup: boolean = true, public animationType: number = 1) {
|
|
118
|
+
super(PTRCommandType.SHOW_MY_CAR_SITE);
|
|
118
119
|
}
|
|
119
120
|
}
|