react-native-pointr 0.0.0 → 8.14.3
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 +30 -0
- package/README.md +306 -3
- package/android/build.gradle +2 -2
- package/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/java/com/pointr/PTRMapWidgetCommandType.kt +17 -0
- package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +605 -0
- package/android/src/main/java/com/pointr/PointrMapWidgetActivity.kt +102 -20
- package/android/src/main/java/com/pointr/PointrModule.kt +92 -21
- package/android/src/main/java/com/pointr/PointrPackage.kt +1 -1
- package/ios/PTRMapWidgetContainerView.h +19 -0
- package/ios/PTRMapWidgetContainerView.m +283 -0
- package/ios/PTRMapWidgetManager.m +165 -0
- package/ios/PTRNativeLibrary.h +0 -8
- package/ios/PTRNativeLibrary.m +8 -8
- package/ios/PointrApp.swift +93 -32
- package/package.json +1 -1
- package/react-native-pointr.podspec +1 -1
- package/src/PTRCommand.ts +79 -0
- package/src/PTRMapWidgetUtils.ts +66 -0
package/ios/PointrApp.swift
CHANGED
|
@@ -21,6 +21,8 @@ import PointrKit
|
|
|
21
21
|
|
|
22
22
|
@objc public static let sharedApp = PointrApp()
|
|
23
23
|
|
|
24
|
+
@objc public static var shouldRequestPermissionsAtStartup: Bool = true
|
|
25
|
+
|
|
24
26
|
let params = PTRParams()
|
|
25
27
|
|
|
26
28
|
let dispatchGroup = DispatchGroup()
|
|
@@ -29,7 +31,6 @@ import PointrKit
|
|
|
29
31
|
|
|
30
32
|
var configuration: Dictionary<String,Any>? = nil
|
|
31
33
|
|
|
32
|
-
private var mapDispatchGroupDataManager = [Int32: [DispatchGroup]]()
|
|
33
34
|
private var dispatchGroupSiteManager = [DispatchGroup]()
|
|
34
35
|
|
|
35
36
|
var rootViewController: UIViewController? = nil
|
|
@@ -78,10 +79,10 @@ import PointrKit
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
func initialize(licenseKey: String, baseUrl: String, clientIdentifier: String, environment: String = "prod", logLevel: Int = 4, rootViewController: UIViewController) {
|
|
82
|
+
Pointr.shared.permissionManager?.delegate = self
|
|
81
83
|
self.rootViewController = rootViewController
|
|
82
|
-
self.params.mode =
|
|
84
|
+
self.params.mode = PointrReleaseMode()
|
|
83
85
|
// No need to set environment
|
|
84
|
-
// self.params.environment = self.getEnvironmentFromString(env: environment)
|
|
85
86
|
self.params.loggerLevel = PTRLoggerLevel.init(rawValue: Int32(logLevel)) ?? .error
|
|
86
87
|
|
|
87
88
|
// Enter you license key
|
|
@@ -172,6 +173,18 @@ import PointrKit
|
|
|
172
173
|
Pointr.shared.stop()
|
|
173
174
|
}
|
|
174
175
|
|
|
176
|
+
func requestPermissions() {
|
|
177
|
+
guard let permissionManager = Pointr.shared.permissionManager else { return }
|
|
178
|
+
if (!permissionManager.hasLocationAuthorizationWhenInUseOrAlways) {
|
|
179
|
+
permissionManager.requestLocationAuthorizationPermissionForWhenInUse()
|
|
180
|
+
}
|
|
181
|
+
if #available(iOS 17.4, *) {
|
|
182
|
+
if (!permissionManager.hasCoreMotionAuthorization) {
|
|
183
|
+
permissionManager.requestCoreMotionAuthorizationPermission()
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
175
188
|
func showSite(siteExternalIdentifier id: String, animationType:Int, completion: @escaping (String?) -> Void) {
|
|
176
189
|
func showSiteWithCompletion(completion: @escaping (String?) -> Void) {
|
|
177
190
|
self.initializeMapWidget()
|
|
@@ -307,7 +320,7 @@ import PointrKit
|
|
|
307
320
|
return
|
|
308
321
|
}
|
|
309
322
|
|
|
310
|
-
if !self.loadData(for: site
|
|
323
|
+
if !self.loadData(for: site) {
|
|
311
324
|
completion("Data are not ready for site: \(siteExternalIdentifier)")
|
|
312
325
|
return
|
|
313
326
|
}
|
|
@@ -351,9 +364,7 @@ import PointrKit
|
|
|
351
364
|
}
|
|
352
365
|
|
|
353
366
|
func getSite(with siteExternalIdentifier: String, siteManager: PTRSiteManagerInterface, timeoutInSeconds: Int = 15) -> PTRSite? {
|
|
354
|
-
if
|
|
355
|
-
return site
|
|
356
|
-
} else {
|
|
367
|
+
if siteManager.sites().isEmpty {
|
|
357
368
|
let dispatchGroup = DispatchGroup()
|
|
358
369
|
self.dispatchGroupSiteManager.append(dispatchGroup)
|
|
359
370
|
dispatchGroup.enter()
|
|
@@ -364,19 +375,26 @@ import PointrKit
|
|
|
364
375
|
return siteManager.site(withExternalIdentifier: siteExternalIdentifier)
|
|
365
376
|
}
|
|
366
377
|
|
|
367
|
-
func loadData(for site: PTRSite,
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
let
|
|
372
|
-
|
|
373
|
-
self.mapDispatchGroupDataManager[site.internalIdentifier]?.append(dispatchGroup)
|
|
374
|
-
dataManager.addListener(self)
|
|
375
|
-
dispatchGroup.enter()
|
|
378
|
+
func loadData(for site: PTRSite, timeoutInSeconds: Int = 15) -> Bool {
|
|
379
|
+
guard let poiManager = Pointr.shared.poiManager else { return false }
|
|
380
|
+
guard !poiManager.hasContent(for: site) else { return true }
|
|
381
|
+
guard let dataManager = Pointr.shared.dataManager else { return false }
|
|
382
|
+
let listener = DataManagerListener(site: site)
|
|
383
|
+
dataManager.addListener(listener)
|
|
376
384
|
dataManager.loadData(forSite: site.internalIdentifier, shouldRespectCachePolicy: false)
|
|
377
|
-
|
|
378
|
-
dataManager.removeListener(
|
|
379
|
-
return
|
|
385
|
+
listener.wait(timeoutInSeconds)
|
|
386
|
+
dataManager.removeListener(listener)
|
|
387
|
+
return poiManager.hasContent(for: site)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
func waitForThemeManager(timeoutInSeconds: Int = 5) {
|
|
391
|
+
let themeManager = PTRMapWidgetThemeManager()
|
|
392
|
+
let listener = ThemeManagerListener()
|
|
393
|
+
themeManager.addListener(listener)
|
|
394
|
+
if (!themeManager.isConfigurationReady) {
|
|
395
|
+
listener.wait(timeoutInSeconds)
|
|
396
|
+
}
|
|
397
|
+
themeManager.removeListener(listener)
|
|
380
398
|
}
|
|
381
399
|
|
|
382
400
|
func getAnimationTypeFromInt(value: Int) -> PTRMapAnimationType {
|
|
@@ -393,6 +411,7 @@ import PointrKit
|
|
|
393
411
|
|
|
394
412
|
func initializeMapWidget() {
|
|
395
413
|
if self.viewController != nil { return }
|
|
414
|
+
waitForThemeManager()
|
|
396
415
|
self.viewController = PTRMapWidgetViewController(configuration: getMapWidgetConfiguration())
|
|
397
416
|
self.viewController?.exitButton?.addListener(self)
|
|
398
417
|
self.viewController?.mapViewController.addListener(self)
|
|
@@ -560,22 +579,64 @@ extension PointrApp: PTRSiteManagerDelegate {
|
|
|
560
579
|
}
|
|
561
580
|
}
|
|
562
581
|
|
|
563
|
-
extension PointrApp: PTRDataManagerDelegate {
|
|
564
|
-
public func onDataManagerCompleteAll(for site: PTRSite, isSuccessful: Bool, dataFromOnline isOnlineData: Bool, errorMessages: [NSNumber : String]) {
|
|
565
|
-
if (!isOnlineData) {
|
|
566
|
-
return
|
|
567
|
-
}
|
|
568
|
-
while(self.mapDispatchGroupDataManager[site.internalIdentifier]?.isEmpty == false) {
|
|
569
|
-
if let dispatchGroup = self.mapDispatchGroupDataManager[site.internalIdentifier]?.removeLast() {
|
|
570
|
-
dispatchGroup.leave()
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
|
|
576
582
|
// TODO: remove below code when we have parameter to hide whole pathFindingViewController
|
|
577
583
|
extension PointrApp: PTRMapWidgetEventsListener {
|
|
578
584
|
public func mapWidgetWillPresentPathFinding(_ mapWidget: PTRMapWidgetViewController, pathFinding: PTRPathFindingViewController) {
|
|
579
585
|
pathFinding.view.isHidden = !isRouteFooterViewEnabled && !mapWidget.configuration.isRouteHeaderViewEnabled
|
|
580
586
|
}
|
|
581
587
|
}
|
|
588
|
+
|
|
589
|
+
extension PointrApp: PTRPermissionManagerDelegate {
|
|
590
|
+
public func permissionManagerShouldRequestBluetoothServicesPermission(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
591
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
592
|
+
}
|
|
593
|
+
public func permissionManagerShouldRequestBluetoothAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
594
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
595
|
+
}
|
|
596
|
+
public func permissionManagerShouldRequestCoreMotionAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
597
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
598
|
+
}
|
|
599
|
+
public func permissionManagerShouldRequestLocationAuthorizationPermissionForWhenInUse(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
600
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
601
|
+
}
|
|
602
|
+
public func permissionManagerShouldRequestLocationAuthorizationPermissionForAlways(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
603
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
604
|
+
}
|
|
605
|
+
public func permissionManagerShouldRequestUserNotificationAuthorizationPermission(_ permissionManager: PTRPermissionManager) -> Bool {
|
|
606
|
+
return PointrApp.shouldRequestPermissionsAtStartup
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
class DataManagerListener: NSObject, PTRDataManagerDelegate {
|
|
611
|
+
let dispatchGroup = DispatchGroup()
|
|
612
|
+
let site: PTRSite
|
|
613
|
+
init(site: PTRSite) {
|
|
614
|
+
self.site = site
|
|
615
|
+
super.init()
|
|
616
|
+
dispatchGroup.enter()
|
|
617
|
+
}
|
|
618
|
+
func onDataManagerCompleteAll(for site: PTRSite, isSuccessful: Bool, dataFromOnline isOnlineData: Bool, errorMessages: [NSNumber : String]) {
|
|
619
|
+
guard isOnlineData else {return}
|
|
620
|
+
dispatchGroup.leave()
|
|
621
|
+
}
|
|
622
|
+
func wait(_ seconds: Int = 15) {
|
|
623
|
+
_ = dispatchGroup.wait(wallTimeout: .now() + DispatchTimeInterval.seconds(seconds))
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
class ThemeManagerListener: NSObject, PTRMapWidgetThemeManagerListener {
|
|
628
|
+
let dispatchGroup = DispatchGroup()
|
|
629
|
+
|
|
630
|
+
override init() {
|
|
631
|
+
super.init()
|
|
632
|
+
dispatchGroup.enter()
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
func themeManagerConfigurationReady() {
|
|
636
|
+
dispatchGroup.leave()
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
func wait(_ seconds: Int = 5) {
|
|
640
|
+
_ = dispatchGroup.wait(wallTimeout: .now() + DispatchTimeInterval.seconds(seconds))
|
|
641
|
+
}
|
|
642
|
+
}
|
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", "8
|
|
19
|
+
s.dependency "PointrKit", "~> 8"
|
|
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.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command types supported by the Pointr SDK
|
|
3
|
+
*/
|
|
4
|
+
export enum PTRCommandType {
|
|
5
|
+
SITE = "site",
|
|
6
|
+
BUILDING = "building",
|
|
7
|
+
LEVEL = "level",
|
|
8
|
+
POI = "poi",
|
|
9
|
+
PATH = "path",
|
|
10
|
+
STATIC_PATH = "staticPath"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Base class for all Pointr SDK commands
|
|
14
|
+
* @param type - the command type
|
|
15
|
+
*/
|
|
16
|
+
export abstract class PTRCommand {
|
|
17
|
+
constructor(public type: PTRCommandType = PTRCommandType.SITE) { }
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Command to show a site
|
|
21
|
+
* @param site - the site to show
|
|
22
|
+
*/
|
|
23
|
+
export class PTRSiteCommand extends PTRCommand {
|
|
24
|
+
constructor(public site: string) {
|
|
25
|
+
super(PTRCommandType.SITE);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Command to show a building
|
|
30
|
+
* @param site - the site to show
|
|
31
|
+
* @param building - the building to show
|
|
32
|
+
*/
|
|
33
|
+
export class PTRBuildingCommand extends PTRCommand {
|
|
34
|
+
constructor(public site: string, public building: string) {
|
|
35
|
+
super(PTRCommandType.BUILDING);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Command to show a level
|
|
40
|
+
* @param site - the site to show
|
|
41
|
+
* @param building - the building to show
|
|
42
|
+
* @param level - the level to show
|
|
43
|
+
*/
|
|
44
|
+
export class PTRLevelCommand extends PTRCommand {
|
|
45
|
+
constructor(public site: string, public building: string, public level: number) {
|
|
46
|
+
super(PTRCommandType.LEVEL);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Command to show a POI
|
|
51
|
+
* @param site - the site that has the POI
|
|
52
|
+
* @param poi - the POI to show
|
|
53
|
+
*/
|
|
54
|
+
export class PTRPoiCommand extends PTRCommand {
|
|
55
|
+
constructor(public site: string, public poi: string) {
|
|
56
|
+
super(PTRCommandType.POI);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Command to show a path
|
|
61
|
+
* @param site - the site that has the POI
|
|
62
|
+
* @param poi - the POI to show the path to from the current location
|
|
63
|
+
*/
|
|
64
|
+
export class PTRPathCommand extends PTRCommand {
|
|
65
|
+
constructor(public site: string, public poi: string) {
|
|
66
|
+
super(PTRCommandType.PATH);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Command to show a static path
|
|
71
|
+
* @param site - the site that has the POIs
|
|
72
|
+
* @param fromPoi - the POI to start the path from
|
|
73
|
+
* @param toPoi - the POI to end the path at
|
|
74
|
+
*/
|
|
75
|
+
export class PTRStaticPathCommand extends PTRCommand {
|
|
76
|
+
constructor(public site: string, public fromPoi: string, public toPoi: string) {
|
|
77
|
+
super(PTRCommandType.STATIC_PATH);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { UIManager } from 'react-native';
|
|
2
|
+
import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRCommand, PTRCommandType } from 'react-native-pointr/src/PTRCommand';
|
|
3
|
+
/**
|
|
4
|
+
* Show the map widget with the given command
|
|
5
|
+
* @param reactTag view tag of the map widget
|
|
6
|
+
* @param ptrCommand command to show the map widget
|
|
7
|
+
*/
|
|
8
|
+
export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
9
|
+
console.log(`Showing map widget with command: ${ptrCommand.type}`);
|
|
10
|
+
switch (ptrCommand.type) {
|
|
11
|
+
case PTRCommandType.SITE: {
|
|
12
|
+
const siteCommand = ptrCommand as PTRSiteCommand;
|
|
13
|
+
UIManager.dispatchViewManagerCommand(
|
|
14
|
+
reactTag,
|
|
15
|
+
ptrCommand.type,
|
|
16
|
+
[siteCommand.site],
|
|
17
|
+
);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
case PTRCommandType.BUILDING: {
|
|
21
|
+
const buildingCommand = ptrCommand as PTRBuildingCommand;
|
|
22
|
+
UIManager.dispatchViewManagerCommand(
|
|
23
|
+
reactTag,
|
|
24
|
+
ptrCommand.type,
|
|
25
|
+
[buildingCommand.site, buildingCommand.building],
|
|
26
|
+
);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case PTRCommandType.LEVEL: {
|
|
30
|
+
const levelCommand = ptrCommand as PTRLevelCommand;
|
|
31
|
+
UIManager.dispatchViewManagerCommand(
|
|
32
|
+
reactTag,
|
|
33
|
+
ptrCommand.type,
|
|
34
|
+
[levelCommand.site, levelCommand.building, levelCommand.level],
|
|
35
|
+
);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case PTRCommandType.POI: {
|
|
39
|
+
const poiCommand = ptrCommand as PTRPoiCommand;
|
|
40
|
+
UIManager.dispatchViewManagerCommand(
|
|
41
|
+
reactTag,
|
|
42
|
+
ptrCommand.type,
|
|
43
|
+
[poiCommand.site, poiCommand.poi],
|
|
44
|
+
);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case PTRCommandType.PATH: {
|
|
48
|
+
const pathCommand = ptrCommand as PTRPathCommand;
|
|
49
|
+
UIManager.dispatchViewManagerCommand(
|
|
50
|
+
reactTag,
|
|
51
|
+
ptrCommand.type,
|
|
52
|
+
[pathCommand.site, pathCommand.poi],
|
|
53
|
+
);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case PTRCommandType.STATIC_PATH: {
|
|
57
|
+
const staticPathCommand = ptrCommand as PTRStaticPathCommand;
|
|
58
|
+
UIManager.dispatchViewManagerCommand(
|
|
59
|
+
reactTag,
|
|
60
|
+
ptrCommand.type,
|
|
61
|
+
[staticPathCommand.site, staticPathCommand.fromPoi, staticPathCommand.toPoi],
|
|
62
|
+
);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|