react-native-pointr 8.16.1 → 9.2.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.
@@ -1,636 +0,0 @@
1
- //
2
- // PointrApp.swift
3
- // Pods-PointrSample
4
- //
5
- // Created by Furkan Erdem Perşembe on 15.04.2020.
6
- //
7
-
8
- import UIKit
9
- import PointrKit
10
-
11
- @objc public protocol PTREventManagerDelegate {
12
- func onPositionManagerCalculatedLocation(location: [String: Any])
13
- func onBuildingClicked(_ building: [String: Any])
14
- func onSiteClicked(_ site: [String: Any])
15
- }
16
-
17
- // Class responsible of bridging UI and Pointr SDK with outside world. This class is being used by PTRNativeLibrary.
18
- @objc public class PointrApp: NSObject {
19
-
20
- @objc public weak var eventManagerDelegate: PTREventManagerDelegate?
21
-
22
- @objc public static let sharedApp = PointrApp()
23
-
24
- @objc public static var shouldRequestPermissionsAtStartup: Bool = true
25
-
26
- @objc public static let params = PTRParams()
27
-
28
- let dispatchGroup = DispatchGroup()
29
-
30
- var ptrMapWidget: PTRMapWidgetViewController? = nil
31
-
32
- var configuration: Dictionary<String,Any>? = nil
33
-
34
- private var dispatchGroupSiteManager = [DispatchGroup]()
35
-
36
- var rootViewController: UIViewController? = nil
37
-
38
- // TODO: remove the code below when we have widget configuration to remove pathFindingViewController
39
- var isRouteFooterViewEnabled = true
40
-
41
- private override init () {
42
- super.init()
43
- }
44
- }
45
-
46
- // MARK: - PTRNativeLibrary methods
47
-
48
- @objc public extension PointrApp {
49
-
50
-
51
- func covertToDictionary(_ location: PTRCalculatedLocation) -> [String: Any] {
52
- var dictionary = [String: Any]()
53
- if let siteInternalIdentifier = location.site?.internalIdentifier {
54
- dictionary.updateValue(siteInternalIdentifier, forKey: "siteInternalIdentifier")
55
- }
56
- if let buildingInternalIdentifier = location.building?.internalIdentifier {
57
- dictionary.updateValue(buildingInternalIdentifier, forKey: "buildingInternalIdentifier")
58
- }
59
- if let siteExternalIdentifier = location.site?.externalIdentifier {
60
- dictionary.updateValue(siteExternalIdentifier, forKey: "siteExternalIdentifier")
61
- }
62
- if let buildingExternalIdentifier = location.building?.externalIdentifier {
63
- dictionary.updateValue(buildingExternalIdentifier, forKey: "buildingExternalIdentifier")
64
- }
65
- if let levelIndex = location.level?.index {
66
- dictionary.updateValue(levelIndex, forKey: "levelIndex")
67
- }
68
- if location.coordinate.latitude != CLLocationDegrees(PTRPositioningTypes.invalidFloat()) && location.coordinate.longitude != CLLocationDegrees(PTRPositioningTypes.invalidFloat()) {
69
- dictionary.updateValue(location.coordinate.latitude, forKey: "latitude")
70
- dictionary.updateValue(location.coordinate.longitude, forKey: "longitude")
71
- }
72
- if location.accuracy != Double(PTRPositioningTypes.invalidFloat()) {
73
- dictionary.updateValue(location.accuracy, forKey: "accuracy")
74
- }
75
- if (location.headingAccuracyClass == .high) {
76
- dictionary.updateValue(location.heading, forKey: "heading")
77
- }
78
- return dictionary
79
- }
80
-
81
- func initialize(licenseKey: String, baseUrl: String, clientIdentifier: String, environment: String = "prod", logLevel: Int = 4, rootViewController: UIViewController) {
82
- Pointr.shared.permissionManager?.delegate = self
83
- self.rootViewController = rootViewController
84
- PointrApp.params.mode = PointrDebugMode()
85
- // No need to set environment
86
- PointrApp.params.loggerLevel = PTRLoggerLevel.init(rawValue: Int32(logLevel)) ?? .error
87
-
88
- // Enter you license key
89
- PointrApp.params.licenseKey = licenseKey
90
- PointrApp.params.baseUrl = baseUrl
91
- PointrApp.params.clientIdentifier = clientIdentifier
92
- }
93
-
94
- func getEnvironmentFromString(env: String) -> PTREnvironment {
95
- if env == "prod" {
96
- return .production
97
- } else if env == "preprod" {
98
- return .preProduction
99
- } else if env == "qa" {
100
- return .QA
101
- } else if env == "dev" {
102
- return .development
103
- } else {
104
- return .production
105
- }
106
- }
107
-
108
- func setPointrMapWidgetConfiguration(string: String) {
109
- guard let data = string.data(using: .utf8) else {
110
- Ploge("String does not have valid data")
111
- return
112
- }
113
- do {
114
- guard let jsonObject = try JSONSerialization.jsonObject(with: data) as? Dictionary<String,Any> else {
115
- Ploge("Bad json")
116
- return
117
- }
118
- configuration = jsonObject
119
- } catch let error as NSError {
120
- Ploge("Error parsing json: \(string)\n\(error)")
121
- }
122
- }
123
-
124
- func getMapWidgetConfiguration() -> PTRMapWidgetConfiguration {
125
- let mapWidgetConfiguration = PTRMapWidgetConfiguration.defaultConfiguration()
126
- guard let configuration else {
127
- return mapWidgetConfiguration
128
- }
129
- let mirror = Mirror(reflecting: mapWidgetConfiguration)
130
- for attr in mirror.children {
131
- guard let key = attr.label else {
132
- continue
133
- }
134
- // only set boolean values
135
- guard let value = configuration[key] as? Bool, attr.value is Bool else {
136
- continue
137
- }
138
- mapWidgetConfiguration.setValue(value, forKey: key)
139
- }
140
- // TODO: remove the code below when we have widget configuration to hide pathFindingViewController
141
- // check if navigation footer view needs to be disabled as well.
142
- if let isRouteFooterViewEnabled = configuration["isRouteFooterViewEnabled"] as? Bool {
143
- self.isRouteFooterViewEnabled = isRouteFooterViewEnabled
144
- }
145
- // for exit button configuration check for isExitButtonEnabled key to make the api same with android
146
- if let value = configuration["isExitButtonShown"] as? Bool {
147
- if value {
148
- mapWidgetConfiguration.exitButtonConfiguration = PTRMapwidgetExitButtonConfiguration(preferredPosition: .topRight, visibility: .alwaysVisible)
149
- } else {
150
- mapWidgetConfiguration.exitButtonConfiguration = PTRMapwidgetExitButtonConfiguration(preferredPosition: .topRight, visibility: .notVisible)
151
- }
152
- } else {
153
- mapWidgetConfiguration.exitButtonConfiguration = PTRMapwidgetExitButtonConfiguration(preferredPosition: .topRight, visibility: .automatic)
154
- }
155
- return mapWidgetConfiguration
156
- }
157
-
158
- func start(completion: @escaping (String) -> Void) {
159
- let dispatchGroup = DispatchGroup()
160
- dispatchGroup.enter()
161
- Pointr.shared.start(with: PointrApp.params) { state in
162
- if (state == .running || state.rawValue <= 0) {
163
- dispatchGroup.leave()
164
- }
165
- }
166
- dispatchGroup.wait()
167
- if Pointr.shared.state == .running {
168
- Pointr.shared.positionManager?.addListener(self)
169
- }
170
-
171
- completion(PointrApp.getPointrStateStringFromPointrState(state: Pointr.shared.state))
172
- }
173
-
174
- func stop() {
175
- Pointr.shared.positionManager?.removeListener(self)
176
- Pointr.shared.stop()
177
- }
178
-
179
- func requestPermissions() {
180
- guard let permissionManager = Pointr.shared.permissionManager else { return }
181
- if (!permissionManager.hasLocationAuthorizationWhenInUseOrAlways) {
182
- permissionManager.requestLocationAuthorizationPermissionForWhenInUse()
183
- }
184
- if #available(iOS 17.4, *) {
185
- if (!permissionManager.hasCoreMotionAuthorization) {
186
- permissionManager.requestCoreMotionAuthorizationPermission()
187
- }
188
- }
189
- }
190
-
191
- func showSite(siteExternalIdentifier id: String, animationType:Int, completion: @escaping (String?) -> Void) {
192
- func showSiteWithCompletion(completion: @escaping (String?) -> Void) {
193
- self.initializeMapWidget()
194
- self.ptrMapWidget!.showSite(siteExternalIdentifier: id, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
195
- completion(self.getErrorStringFromMapWidgetError(error: error))
196
- }
197
- self.presentMapWidgetIfNotPresented()
198
- }
199
-
200
- if Pointr.shared.state != .running {
201
- start() { state in
202
- if state == "running" {
203
- showSiteWithCompletion(completion: completion)
204
- } else {
205
- completion("starting Pointr resulted in \(state) state")
206
- }
207
- }
208
- } else {
209
- showSiteWithCompletion(completion: completion)
210
- }
211
- }
212
-
213
- func showBuilding(siteExternalIdentifier: String, buildingExternalIdentifier: String, animationType:Int, completion: @escaping (String?) -> Void) {
214
- func showBuildingWithCompletion(completion: @escaping (String?) -> Void) {
215
- self.initializeMapWidget()
216
- self.ptrMapWidget!.showBuilding(siteExternalIdentifier: siteExternalIdentifier, buildingExternalIdentifier: buildingExternalIdentifier, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
217
- completion(self.getErrorStringFromMapWidgetError(error: error))
218
- }
219
- self.presentMapWidgetIfNotPresented()
220
- }
221
-
222
- if Pointr.shared.state != .running {
223
- start() { state in
224
- if state == "running" {
225
- showBuildingWithCompletion(completion: completion)
226
- } else {
227
- completion("starting Pointr resulted in \(state) state")
228
- }
229
- }
230
- } else {
231
- showBuildingWithCompletion(completion: completion)
232
- }
233
- }
234
-
235
- func showLevel(siteExternalIdentifier: String, buildingExternalIdentifier: String, levelIndex: Int, animationType:Int, completion: @escaping (String?) -> Void) {
236
- func showLevelWithCompletion(completion: @escaping (String?) -> Void) {
237
- self.initializeMapWidget()
238
- self.ptrMapWidget!.showLevel(siteExternalIdentifier: siteExternalIdentifier, buildingExternalIdentifier: buildingExternalIdentifier, levelIndex: levelIndex, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
239
- completion(self.getErrorStringFromMapWidgetError(error: error))
240
- }
241
- self.presentMapWidgetIfNotPresented()
242
- }
243
-
244
- if Pointr.shared.state != .running {
245
- start() { state in
246
- if state == "running" {
247
- showLevelWithCompletion(completion: completion)
248
- } else {
249
- completion("starting Pointr resulted in \(state) state")
250
- }
251
- }
252
- } else {
253
- showLevelWithCompletion(completion: completion)
254
- }
255
- }
256
-
257
- func showPoiDetails(siteExternalIdentifier id: String, poiExternalIdentifier: String, animationType:Int, completion: @escaping (String?) -> Void) {
258
- func showPoiDetailsWithCompletion(completion: @escaping (String?) -> Void) {
259
- self.initializeMapWidget()
260
- self.ptrMapWidget!.showPoiDetails(siteExternalIdentifier: id, poiExternalIdentifier: poiExternalIdentifier, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
261
- completion(self.getErrorStringFromMapWidgetError(error: error))
262
- }
263
- self.presentMapWidgetIfNotPresented()
264
- }
265
-
266
- if Pointr.shared.state != .running {
267
- start() { state in
268
- if state == "running" {
269
- showPoiDetailsWithCompletion(completion: completion)
270
- } else {
271
- completion("starting Pointr resulted in \(state) state")
272
- }
273
- }
274
- } else {
275
- showPoiDetailsWithCompletion(completion: completion)
276
- }
277
- }
278
-
279
- func showPathFindingToPoi(siteExternalIdentifier id: String, poiExternalIdentifier: String, animationType:Int, completion: @escaping (String?) -> Void) {
280
- func showPathFindingToPoiWithCompletion(completion: @escaping (String?) -> Void) {
281
- self.initializeMapWidget()
282
- self.ptrMapWidget!.showPathFinding(siteExternalIdentifier: id, poiExternalIdentifier: poiExternalIdentifier, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
283
- completion(self.getErrorStringFromMapWidgetError(error: error))
284
- }
285
- self.presentMapWidgetIfNotPresented()
286
- }
287
-
288
- if Pointr.shared.state != .running {
289
- start() { state in
290
- if state == "running" {
291
- showPathFindingToPoiWithCompletion(completion: completion)
292
- } else {
293
- completion("starting Pointr resulted in \(state) state")
294
- }
295
- }
296
- } else {
297
- showPathFindingToPoiWithCompletion(completion: completion)
298
- }
299
- }
300
-
301
-
302
- func showPathFindingBetweenPOIs(siteExternalIdentifier: String, sourcePoiExternalIdentifier: String, destinationPoiExternalIdentifier: String, animationType:Int, completion: @escaping (String?) -> Void) {
303
- if Pointr.shared.state != .running {
304
- start() { state in
305
- if state != "running" {
306
- completion("starting Pointr resulted in \(state) state")
307
- return
308
- }
309
- }
310
- }
311
-
312
- DispatchQueue.global().async {
313
- guard let dataManager = Pointr.shared.dataManager,
314
- let siteManager = Pointr.shared.siteManager,
315
- let poiManager = Pointr.shared.poiManager,
316
- let pathManager = Pointr.shared.pathManager else {
317
- completion("Managers are not ready")
318
- return
319
- }
320
-
321
- guard let site = self.getSite(with: siteExternalIdentifier, siteManager: siteManager) else {
322
- completion("Could not find site \(siteExternalIdentifier)")
323
- return
324
- }
325
-
326
- if !self.loadData(for: site) {
327
- completion("Data are not ready for site: \(siteExternalIdentifier)")
328
- return
329
- }
330
-
331
- guard let from = poiManager.pois(for: site, withExternalIdentifier: sourcePoiExternalIdentifier) else {
332
- completion("Could not find poi: \(sourcePoiExternalIdentifier) within site: \(siteExternalIdentifier)")
333
- return
334
- }
335
-
336
- guard let to = poiManager.pois(for: site, withExternalIdentifier: destinationPoiExternalIdentifier) else {
337
- completion("Could not find poi: \(destinationPoiExternalIdentifier) within site: \(siteExternalIdentifier)")
338
- return
339
- }
340
-
341
- guard let path = pathManager.calculatePath(fromLocation: from.location, toNearestLocationIn: [to.location]) else {
342
- completion("Unable to calculate path between locations")
343
- return
344
- }
345
-
346
- guard let fromLevel = from.location.level else {
347
- completion("Starting poi is not within any level")
348
- return
349
- }
350
- DispatchQueue.main.async {
351
- self.initializeMapWidget()
352
- self.presentMapWidgetIfNotPresented()
353
- self.ptrMapWidget!.showLevel(fromLevel, animationType: self.getAnimationTypeFromInt(value: animationType)) { error in
354
- if let e = error {
355
- completion(self.getErrorStringFromMapWidgetError(error: e))
356
- return
357
- }
358
- let layer = PTRMapSymbolLayer(identifier: UUID().uuidString)
359
- self.ptrMapWidget?.mapViewController.addLayer(layer)
360
- self.ptrMapWidget?.mapViewController.addFeatures([to, from], toLayer: layer.identifier)
361
- self.ptrMapWidget?.mapViewController.zoomToCoordinate(to.coordinate)
362
- self.ptrMapWidget?.mapViewController.currentPath = path
363
- completion(nil)
364
- }
365
- }
366
- }
367
- }
368
-
369
- func getSite(with siteExternalIdentifier: String, siteManager: PTRSiteManagerInterface, timeoutInSeconds: Int = 15) -> PTRSite? {
370
- if siteManager.sites().isEmpty {
371
- let dispatchGroup = DispatchGroup()
372
- self.dispatchGroupSiteManager.append(dispatchGroup)
373
- dispatchGroup.enter()
374
- siteManager.addListener(self)
375
- _ = dispatchGroup.wait(wallTimeout: .now() + DispatchTimeInterval.seconds(timeoutInSeconds))
376
- siteManager.removeListener(self)
377
- }
378
- return siteManager.site(withExternalIdentifier: siteExternalIdentifier)
379
- }
380
-
381
- func loadData(for site: PTRSite, timeoutInSeconds: Int = 15) -> Bool {
382
- guard let poiManager = Pointr.shared.poiManager else { return false }
383
- guard !poiManager.hasContent(for: site) else { return true }
384
- guard let dataManager = Pointr.shared.dataManager else { return false }
385
- let listener = DataManagerListener(site: site)
386
- dataManager.addListener(listener)
387
- dataManager.loadData(forSite: site.internalIdentifier, shouldRespectCachePolicy: false)
388
- listener.wait(timeoutInSeconds)
389
- dataManager.removeListener(listener)
390
- return poiManager.hasContent(for: site)
391
- }
392
-
393
- func waitForThemeManager(timeoutInSeconds: Int = 5) {
394
- let themeManager = PTRMapWidgetThemeManager()
395
- let listener = ThemeManagerListener()
396
- themeManager.addListener(listener)
397
- if (!themeManager.isConfigurationReady) {
398
- listener.wait(timeoutInSeconds)
399
- }
400
- themeManager.removeListener(listener)
401
- }
402
-
403
- func getAnimationTypeFromInt(value: Int) -> PTRMapAnimationType {
404
- if value == 0 {
405
- return .none
406
- } else if value == 1 {
407
- return .standard
408
- } else if value == 2 {
409
- return .flyOver
410
- } else {
411
- return .none
412
- }
413
- }
414
-
415
- func initializeMapWidget() {
416
- if self.ptrMapWidget != nil { return }
417
- waitForThemeManager()
418
- self.ptrMapWidget = PTRMapWidgetViewController(configuration: getMapWidgetConfiguration())
419
- self.ptrMapWidget?.exitButton?.addListener(self)
420
- self.ptrMapWidget?.mapViewController.addListener(self)
421
- }
422
-
423
- func presentMapWidgetIfNotPresented() {
424
- guard let viewController = ptrMapWidget else {
425
- return
426
- }
427
- if viewController.view.window != nil {
428
- return
429
- }
430
- viewController.modalPresentationStyle = .fullScreen
431
- rootViewController?.view.addSubview(viewController.view)
432
- // rootViewController?.present(viewController, animated: true)
433
- // TODO: remove code below when we have widget configuration to hide whole pathFindingViewController
434
- viewController.addListener(self)
435
- }
436
-
437
- func getCurrentLocation(completion: @escaping ([String: Any]?, String?) -> Void) {
438
- func getLocationWithCompletion(completion: @escaping ([String: Any]?, String?) -> Void) {
439
- if let location = Pointr.shared.positionManager?.currentCalculatedLocation {
440
- completion(covertToDictionary(location), nil)
441
- } else {
442
- completion([:], nil)
443
- }
444
- }
445
-
446
- if Pointr.shared.state != .running {
447
- start() { s in
448
- let state = self.getPointrStateFromPointrStateString(string: s)
449
- if state == .running {
450
- getLocationWithCompletion(completion: completion)
451
- } else {
452
- completion(nil, "starting Pointr resulted in \(state) state")
453
- }
454
- }
455
- } else {
456
- getLocationWithCompletion(completion: completion)
457
- }
458
- }
459
-
460
- func getErrorStringFromMapWidgetError(error: PTRMapWidgetError?) -> String {
461
- guard let error = error else {
462
- return ""
463
- }
464
- switch error.type {
465
- case .unknownMapLoading:
466
- return "An unknown error occured when loading map"
467
- case .invalidMapUrl:
468
- return "Map Url is invalid"
469
- case .unknownDataLoading:
470
- return "An unknown error occured when loading data"
471
- case .noSite:
472
- return "There is no site with given id"
473
- case .noBuilding:
474
- return "There is no building with given id"
475
- case .noLevel:
476
- return "There is no level with given index"
477
- case .noPoi:
478
- return "There is no poi with given id"
479
- case .noPosition:
480
- return "Position could not be acquired for path calculation"
481
- case .pathManagerTimeout:
482
- return "Path manager is not ready for site"
483
- case .noPathExist:
484
- return "Path does not exist for poi"
485
- case .noBuildingBounds:
486
- return "No bounds for Building"
487
- case .noSiteBounds:
488
- return "No bounds for Site"
489
- case .invalidCoordinate:
490
- return "Invalid coordinate"
491
- case .pointrNotRunning:
492
- return "Pointr SDK not running when Map Wigdet was initialised"
493
- case .noPoiCategory:
494
- return "There is no poi category with given title"
495
- default:
496
- return "An unknown error occured"
497
- }
498
- }
499
-
500
- @objc static func getPointrStateStringFromPointrState(state: PointrState) -> String {
501
- switch state {
502
- case .running:
503
- return "running"
504
- case .failedRegistration:
505
- return "failed registration"
506
- case .failedValidation:
507
- return "failed validation"
508
- case .failedInvalidDeepLinkUrl:
509
- return "failed invalid deep link url"
510
- case .failedNoInternet:
511
- return "failed no internet"
512
- case .off:
513
- return "off"
514
- default:
515
- return ""
516
- }
517
- }
518
-
519
- func getPointrStateFromPointrStateString(string: String) -> PointrState {
520
- switch (string) {
521
- case "running":
522
- return .running
523
- case "failed registration":
524
- return .failedRegistration
525
- case "failed validation":
526
- return .failedValidation
527
- case "failed invalid deep link url":
528
- return .failedInvalidDeepLinkUrl
529
- case "failed no internet":
530
- return .failedNoInternet
531
- default:
532
- return .off
533
- }
534
- }
535
- }
536
-
537
- extension PointrApp: PTRPositionManagerDelegate {
538
- public func onPositionManagerCalculatedLocation(_ calculatedLocation: PTRCalculatedLocation) {
539
- eventManagerDelegate?.onPositionManagerCalculatedLocation(location: self.covertToDictionary(calculatedLocation))
540
- }
541
- }
542
-
543
- extension PointrApp: PTRExitButtonEventsListener {
544
- public func exitButtonDidTap(_ exitbutton: PointrKit.PTRMapWidgetExitButton) {
545
- self.ptrMapWidget?.view.removeFromSuperview()
546
- self.ptrMapWidget = nil
547
- }
548
- }
549
-
550
- extension PointrApp: PTRMapEventsListener {
551
- public func map(_ map: PTRMapViewController, didReceiveTapOnBuilding building: PTRBuilding) {
552
- eventManagerDelegate?.onBuildingClicked([
553
- "internalIdentifier": building.internalIdentifier,
554
- "externalIdentifier": building.externalIdentifier,
555
- "title": building.title
556
- ])
557
- }
558
- public func map(_ map: PTRMapViewController, didReceiveTapOnSite site: PTRSite) {
559
- eventManagerDelegate?.onSiteClicked([
560
- "internalIdentifier": site.internalIdentifier,
561
- "externalIdentifier": site.externalIdentifier,
562
- "title": site.title
563
- ])
564
- }
565
- }
566
-
567
- extension PointrApp: PTRSiteManagerDelegate {
568
- public func onSiteManagerDataChanged() {
569
- while(!dispatchGroupSiteManager.isEmpty) {
570
- let dispatchGroup = dispatchGroupSiteManager.removeLast()
571
- dispatchGroup.leave()
572
- }
573
- }
574
- }
575
-
576
- // TODO: remove below code when we have parameter to hide whole pathFindingViewController
577
- extension PointrApp: PTRMapWidgetEventsListener {
578
- public func mapWidgetWillPresentPathFinding(_ mapWidget: PTRMapWidgetViewController, pathFinding: PTRPathFindingViewController) {
579
- pathFinding.view.isHidden = !isRouteFooterViewEnabled && !mapWidget.configuration.isRouteHeaderViewEnabled
580
- }
581
- }
582
-
583
- extension PointrApp: PTRPermissionManagerDelegate {
584
- public func permissionManagerShouldRequestBluetoothServicesPermission(_ permissionManager: PTRPermissionManager) -> Bool {
585
- return PointrApp.shouldRequestPermissionsAtStartup
586
- }
587
- public func permissionManagerShouldRequestBluetoothAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
588
- return PointrApp.shouldRequestPermissionsAtStartup
589
- }
590
- public func permissionManagerShouldRequestCoreMotionAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
591
- return PointrApp.shouldRequestPermissionsAtStartup
592
- }
593
- public func permissionManagerShouldRequestLocationAuthorizationPermissionForWhenInUse(_ permissionManager: PTRPermissionManager) -> Bool {
594
- return PointrApp.shouldRequestPermissionsAtStartup
595
- }
596
- public func permissionManagerShouldRequestLocationAuthorizationPermissionForAlways(_ permissionManager: PTRPermissionManager) -> Bool {
597
- return PointrApp.shouldRequestPermissionsAtStartup
598
- }
599
- public func permissionManagerShouldRequestUserNotificationAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
600
- return PointrApp.shouldRequestPermissionsAtStartup
601
- }
602
- }
603
-
604
- class DataManagerListener: NSObject, PTRDataManagerDelegate {
605
- let dispatchGroup = DispatchGroup()
606
- let site: PTRSite
607
- init(site: PTRSite) {
608
- self.site = site
609
- super.init()
610
- dispatchGroup.enter()
611
- }
612
- func onDataManagerCompleteAll(for site: PTRSite, isSuccessful: Bool, dataFromOnline isOnlineData: Bool, errorMessages: [NSNumber : String]) {
613
- guard isOnlineData else {return}
614
- dispatchGroup.leave()
615
- }
616
- func wait(_ seconds: Int = 15) {
617
- _ = dispatchGroup.wait(wallTimeout: .now() + DispatchTimeInterval.seconds(seconds))
618
- }
619
- }
620
-
621
- class ThemeManagerListener: NSObject, PTRMapWidgetThemeManagerListener {
622
- let dispatchGroup = DispatchGroup()
623
-
624
- override init() {
625
- super.init()
626
- dispatchGroup.enter()
627
- }
628
-
629
- func themeManagerConfigurationReady() {
630
- dispatchGroup.leave()
631
- }
632
-
633
- func wait(_ seconds: Int = 5) {
634
- _ = dispatchGroup.wait(wallTimeout: .now() + DispatchTimeInterval.seconds(seconds))
635
- }
636
- }