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
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
#import "PTRMapWidgetContainerView.h"
|
|
2
|
+
|
|
3
|
+
NSString * const kLayerStaticPath = @"static-path";
|
|
4
|
+
|
|
5
|
+
@implementation PTRMapWidgetContainerView
|
|
6
|
+
|
|
7
|
+
- (void) ptrMapWidgetDidEndLoadingWithParameters:(NSDictionary *)parameters {
|
|
8
|
+
if (self.onMapWidgetDidEndLoading) {
|
|
9
|
+
self.onMapWidgetDidEndLoading(parameters);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
-(PTRMapWidgetViewController *) getMapWidget {
|
|
14
|
+
if (self.mapWidget) {
|
|
15
|
+
self.mapWidget.mapViewController.currentPath = nil;
|
|
16
|
+
[self.mapWidget.mapViewController removeAllFeatures];
|
|
17
|
+
[self.mapWidget.mapViewController removeLayerWithLayerIdentifier: kLayerStaticPath];
|
|
18
|
+
return self.mapWidget;
|
|
19
|
+
}
|
|
20
|
+
if ([self waitForPointrState] != PointrStateRunning) {
|
|
21
|
+
NSLog(@"Pointr is not running");
|
|
22
|
+
}
|
|
23
|
+
[self waitForConfiguration];
|
|
24
|
+
NSLog(@"initializing map widget");
|
|
25
|
+
PTRMapWidgetConfiguration *config = [PointrApp.sharedApp getMapWidgetConfiguration];
|
|
26
|
+
PTRMapwidgetExitButtonConfiguration *exitButtonConfiguration = [[PTRMapwidgetExitButtonConfiguration alloc] initWithPreferredPosition:PTRMapwidgetExitButtonPositionTopRight visibility:PTRMapwidgetExitButtonVisibilityNotVisible];
|
|
27
|
+
config.exitButtonConfiguration = exitButtonConfiguration;
|
|
28
|
+
_mapWidget = [[PTRMapWidgetViewController alloc] initWithConfiguration:config];
|
|
29
|
+
[self addSubview: self.mapWidget.view];
|
|
30
|
+
self.mapWidget.view.translatesAutoresizingMaskIntoConstraints = NO;
|
|
31
|
+
[NSLayoutConstraint activateConstraints:@[
|
|
32
|
+
[self.mapWidget.view.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
|
|
33
|
+
[self.mapWidget.view.trailingAnchor constraintEqualToAnchor:self.trailingAnchor],
|
|
34
|
+
[self.mapWidget.view.topAnchor constraintEqualToAnchor:self.topAnchor],
|
|
35
|
+
[self.mapWidget.view.bottomAnchor constraintEqualToAnchor:self.bottomAnchor],
|
|
36
|
+
]];
|
|
37
|
+
return self.mapWidget;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
-(void) showStaticPath:(NSString *) siteExternalIdentifier fromPoiExternalIdentifier:(NSString *) fromPoiExternalIdentifier toPoiExternalIdentifier:(NSString *) toPoiExternalIdentifier {
|
|
41
|
+
[self waitForPointrState];
|
|
42
|
+
[self waitForConfiguration];
|
|
43
|
+
NSMutableDictionary *ptrCommand = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
|
44
|
+
@"staticPath", @"command",
|
|
45
|
+
siteExternalIdentifier, @"siteExternalIdentifier",
|
|
46
|
+
fromPoiExternalIdentifier, @"fromPoiExternalIdentifier",
|
|
47
|
+
toPoiExternalIdentifier, @"toPoiExternalIdentifier",
|
|
48
|
+
nil];
|
|
49
|
+
PTRSite *site = [self getSite: siteExternalIdentifier];
|
|
50
|
+
if (!site) {
|
|
51
|
+
ptrCommand[@"error"] = @"Site not found";
|
|
52
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
53
|
+
NSLog(@"no site found");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
PTRPoi *fromPoi = [self getPoi:site poiExternalIdentifier: fromPoiExternalIdentifier];
|
|
57
|
+
if (!fromPoi) {
|
|
58
|
+
ptrCommand[@"error"] = @"Source poi not found";
|
|
59
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
60
|
+
NSLog(@"Source poi not found");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
PTRPoi *toPoi = [self getPoi:site poiExternalIdentifier: toPoiExternalIdentifier];
|
|
64
|
+
if (!toPoi) {
|
|
65
|
+
ptrCommand[@"error"] = @"Target poi not found";
|
|
66
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
67
|
+
NSLog(@"Destination poi not found");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
[self waitForPath: site];
|
|
71
|
+
id<PTRPathManagerInterface> pathManager = Pointr.shared.pathManager;
|
|
72
|
+
if (!pathManager) {
|
|
73
|
+
ptrCommand[@"error"] = @"Path manager not found";
|
|
74
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
75
|
+
NSLog(@"Path manager not found");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
PTRPath *path = [pathManager calculatePathFromLocation:fromPoi toNearestLocationInArray: @[toPoi]];
|
|
79
|
+
if (!path) {
|
|
80
|
+
ptrCommand[@"error"] = @"Path not found";
|
|
81
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
82
|
+
NSLog(@"Path not found");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
86
|
+
PTRMapWidgetViewController *mapWidget = [self getMapWidget];
|
|
87
|
+
PTRLevel *level = fromPoi.location.level;
|
|
88
|
+
if (!level) {
|
|
89
|
+
[mapWidget showSite:site animationType:PTRMapAnimationTypeStandard completion:^(PTRMapWidgetError * _Nullable error) {
|
|
90
|
+
if (error) {
|
|
91
|
+
ptrCommand[@"error"] = error ? error.errorCode : @"";
|
|
92
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
93
|
+
NSLog(@"Error showing site: %@", error.errorCode);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
[self setStaticPath:mapWidget.mapViewController fromPoi: fromPoi toPoi:toPoi path:path];
|
|
97
|
+
ptrCommand[@"error"] = @"";
|
|
98
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
99
|
+
NSLog(@"ready");
|
|
100
|
+
}];
|
|
101
|
+
} else {
|
|
102
|
+
[mapWidget showLevel:level animationType:PTRMapAnimationTypeStandard completion:^(PTRMapWidgetError * _Nullable error) {
|
|
103
|
+
if (error) {
|
|
104
|
+
ptrCommand[@"error"] = error ? error.errorCode : @"";
|
|
105
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
106
|
+
NSLog(@"Error showing level: %@", error.errorCode);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
[self setStaticPath:mapWidget.mapViewController fromPoi: fromPoi toPoi:toPoi path:path];
|
|
110
|
+
ptrCommand[@"error"] = @"";
|
|
111
|
+
[self ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
112
|
+
NSLog(@"ready");
|
|
113
|
+
}];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
-(void) setStaticPath:(PTRMapViewController *) map fromPoi:(PTRPoi *) fromPoi toPoi:(PTRPoi *) toPoi path:(PTRPath *) path {
|
|
119
|
+
PTRMapSymbolLayer *layer = [[PTRMapSymbolLayer alloc] initWithIdentifier: kLayerStaticPath];
|
|
120
|
+
[map addLayer: layer];
|
|
121
|
+
[map addFeatures:@[fromPoi, toPoi] toLayer:layer.identifier];
|
|
122
|
+
[map zoomToCoordinate:fromPoi.location.coordinate];
|
|
123
|
+
map.currentPath = path;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
-(void) waitForPath:(nonnull PTRSite *) site {
|
|
127
|
+
NSLog(@"waiting for path to be ready");
|
|
128
|
+
id<PTRPathManagerInterface> pathManager = Pointr.shared.pathManager;
|
|
129
|
+
if (!pathManager) return;
|
|
130
|
+
self.site = site;
|
|
131
|
+
self.semaphore = dispatch_semaphore_create(0);
|
|
132
|
+
[pathManager addListener:self];
|
|
133
|
+
if (![pathManager isReadyForSite:site]) {
|
|
134
|
+
// Define a timeout of 5 seconds
|
|
135
|
+
dispatch_time_t timeout = dispatch_walltime(NULL, 5 * NSEC_PER_SEC);
|
|
136
|
+
if (dispatch_semaphore_wait(self.semaphore, timeout) != 0) {
|
|
137
|
+
NSLog(@"Timeout waiting for pathmanager");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
[pathManager removeListener:self];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
- (void)onPathManagerReadyForSite:(nonnull PTRSite *)site {
|
|
144
|
+
if (site.internalIdentifier != self.site.internalIdentifier) return;
|
|
145
|
+
|
|
146
|
+
// Signal the semaphore to unblock the thread
|
|
147
|
+
NSLog(@"path became ready.");
|
|
148
|
+
dispatch_semaphore_signal(self.semaphore);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
-(nullable PTRPoi *) getPoi:(nonnull PTRSite *) site poiExternalIdentifier:(NSString *) poiExternalIdentifier {
|
|
153
|
+
id<PTRPoiManagerInterface> poiManager = Pointr.shared.poiManager;
|
|
154
|
+
if (!poiManager) return nil;
|
|
155
|
+
if (![poiManager hasContentForSite:site]) {
|
|
156
|
+
[self waitForPois: site];
|
|
157
|
+
}
|
|
158
|
+
PTRPoi *poi = [poiManager poisForSite:site withExternalIdentifier:poiExternalIdentifier];
|
|
159
|
+
if (!poi) {
|
|
160
|
+
return [poiManager poisForSite:site withIdentifier:poiExternalIdentifier];
|
|
161
|
+
}
|
|
162
|
+
return poi;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
-(void) waitForPois:(nonnull PTRSite *) site {
|
|
166
|
+
NSLog(@"waiting for data to be ready");
|
|
167
|
+
id<PTRDataManagerInterface> dataManager = Pointr.shared.dataManager;
|
|
168
|
+
if (!dataManager) return;
|
|
169
|
+
self.site = site;
|
|
170
|
+
self.semaphore = dispatch_semaphore_create(0);
|
|
171
|
+
[dataManager addListener:self];
|
|
172
|
+
[dataManager loadDataForSite:site.internalIdentifier];
|
|
173
|
+
if (![dataManager isContentReadyForSite:site.internalIdentifier]) {
|
|
174
|
+
// Define a timeout of 5 seconds
|
|
175
|
+
dispatch_time_t timeout = dispatch_walltime(NULL, 5 * NSEC_PER_SEC);
|
|
176
|
+
// Wait for the semaphore to be signaled or timeout
|
|
177
|
+
if (dispatch_semaphore_wait(self.semaphore, timeout) != 0) {
|
|
178
|
+
NSLog(@"Timeout waiting for datamanager");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
[dataManager removeListener:self];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
- (void)onDataManagerCompleteAllForSite:(nonnull PTRSite *)site
|
|
185
|
+
isSuccessful:(BOOL)isSuccessful
|
|
186
|
+
dataFromOnline:(BOOL)isOnlineData
|
|
187
|
+
errorMessages:(nonnull NSDictionary<NSNumber *, NSString *> *)errorMessages {
|
|
188
|
+
if (!isOnlineData) return;
|
|
189
|
+
if (site.internalIdentifier != self.site.internalIdentifier) return;
|
|
190
|
+
|
|
191
|
+
// Signal the semaphore to unblock the thread
|
|
192
|
+
NSLog(@"data became ready.");
|
|
193
|
+
dispatch_semaphore_signal(self.semaphore);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
-(nullable PTRSite *) getSite:(NSString *) siteExternalIdentifier {
|
|
197
|
+
id<PTRSiteManagerInterface> siteManager = Pointr.shared.siteManager;
|
|
198
|
+
if(!siteManager) return nil;
|
|
199
|
+
if(siteManager.sites.count == 0) {
|
|
200
|
+
[self waitForSites];
|
|
201
|
+
}
|
|
202
|
+
return [siteManager siteWithExternalIdentifier:siteExternalIdentifier];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
-(void) waitForSites {
|
|
206
|
+
|
|
207
|
+
NSLog(@"waiting for sites");
|
|
208
|
+
self.semaphore = dispatch_semaphore_create(0);
|
|
209
|
+
[Pointr.shared.siteManager addListener:self];
|
|
210
|
+
if (![self isConfigurationReady]) {
|
|
211
|
+
// Define a timeout of 5 seconds
|
|
212
|
+
dispatch_time_t timeout = dispatch_walltime(NULL, 5 * NSEC_PER_SEC);
|
|
213
|
+
// Wait for the semaphore to be signaled or timeout
|
|
214
|
+
if (dispatch_semaphore_wait(self.semaphore, timeout) != 0) {
|
|
215
|
+
NSLog(@"Timeout waiting for configuration");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
[Pointr.shared.siteManager removeListener:self];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
-(void) onSiteManagerDataChanged {
|
|
222
|
+
// Signal the semaphore to unblock the thread
|
|
223
|
+
NSLog(@"sites became ready.");
|
|
224
|
+
dispatch_semaphore_signal(self.semaphore);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
-(void) waitForConfiguration {
|
|
228
|
+
NSLog(@"waiting for configuration");
|
|
229
|
+
self.semaphore = dispatch_semaphore_create(0);
|
|
230
|
+
id<PTRConfigurationManagerInterface> configurationManager = Pointr.shared.configurationManager;
|
|
231
|
+
if (!configurationManager) {
|
|
232
|
+
NSLog(@"configuration manager is nil");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
[configurationManager addListener:self];
|
|
236
|
+
if (![self isConfigurationReady]) {
|
|
237
|
+
// Define a timeout of 5 seconds
|
|
238
|
+
dispatch_time_t timeout = dispatch_walltime(NULL, 5 * NSEC_PER_SEC);
|
|
239
|
+
// Wait for the semaphore to be signaled or timeout
|
|
240
|
+
if (dispatch_semaphore_wait(self.semaphore, timeout) != 0) {
|
|
241
|
+
NSLog(@"Timeout waiting for configuration");
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
[configurationManager removeListener:self];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
-(BOOL) isConfigurationReady {
|
|
248
|
+
NSString *styleUrl = Pointr.shared.configurationManager.globalConfiguration.sdkConfiguration.styleJsonUrl;
|
|
249
|
+
NSLog(@"Style: %@", styleUrl);
|
|
250
|
+
if (!styleUrl || styleUrl.length == 0) {
|
|
251
|
+
NSString *styleUrlWithContent = Pointr.shared.configurationManager.globalConfiguration.sdkConfiguration.styleJsonUrlWithContent;
|
|
252
|
+
NSLog(@"Style with content: %@", styleUrlWithContent);
|
|
253
|
+
return styleUrlWithContent && styleUrlWithContent.length != 0;
|
|
254
|
+
}
|
|
255
|
+
return YES;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
-(void) onConfigurationManagerChangedConfiguration {
|
|
259
|
+
// Signal the semaphore to unblock the thread
|
|
260
|
+
NSLog(@"configuration became ready.");
|
|
261
|
+
dispatch_semaphore_signal(self.semaphore);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
- (PointrState) waitForPointrState {
|
|
266
|
+
NSLog(@"waiting for pointr to run");
|
|
267
|
+
self.semaphore = dispatch_semaphore_create(0);
|
|
268
|
+
[[Pointr shared] addListener: self];
|
|
269
|
+
PointrState state = [Pointr shared].state;
|
|
270
|
+
if (state != PointrStateRunning && state > PointrStateOff) {
|
|
271
|
+
dispatch_semaphore_wait(self.semaphore, DISPATCH_TIME_FOREVER);
|
|
272
|
+
}
|
|
273
|
+
[[Pointr shared] removeListener:self];
|
|
274
|
+
return [Pointr shared].state;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
- (void)pointrStateDidChangeTo:(PointrState)state {
|
|
278
|
+
if (state == PointrStateRunning || state <= PointrStateOff) {
|
|
279
|
+
dispatch_semaphore_signal(self.semaphore);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#import <React/RCTViewManager.h>
|
|
2
|
+
#import <React/RCTUIManager.h>
|
|
3
|
+
#import <PointrKit/PointrKit.h>
|
|
4
|
+
#import "PTRMapWidgetContainerView.h"
|
|
5
|
+
|
|
6
|
+
@interface PTRMapWidgetManager: RCTViewManager
|
|
7
|
+
@end
|
|
8
|
+
|
|
9
|
+
@implementation PTRMapWidgetManager
|
|
10
|
+
|
|
11
|
+
RCT_EXPORT_MODULE(PTRMapWidget)
|
|
12
|
+
|
|
13
|
+
RCT_EXPORT_VIEW_PROPERTY(onMapWidgetDidEndLoading, RCTBubblingEventBlock)
|
|
14
|
+
|
|
15
|
+
- (UIView *)view {
|
|
16
|
+
PTRMapWidgetContainerView *view = [[PTRMapWidgetContainerView alloc] init];
|
|
17
|
+
return view;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
RCT_EXPORT_METHOD(site:(nonnull NSNumber*) reactTag siteExternalIdentifier:(NSString*) siteExternalIdentifier) {
|
|
21
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
22
|
+
UIView *view = viewRegistry[reactTag];
|
|
23
|
+
if (!view || ![view isKindOfClass:[PTRMapWidgetContainerView class]]) {
|
|
24
|
+
RCTLogError(@"Cannot find PTRMapWidgetContainerView with tag #%@", reactTag);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
NSLog(@"found PTRMapWidgetContainerView");
|
|
28
|
+
PTRMapWidgetContainerView *ptrMapWidgetContainerView = (PTRMapWidgetContainerView *)view;
|
|
29
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
30
|
+
PTRMapWidgetViewController *mapWidget = [ptrMapWidgetContainerView getMapWidget];
|
|
31
|
+
NSLog(@"calling show site method of mapWidget");
|
|
32
|
+
[mapWidget showSiteWithSiteExternalIdentifier:siteExternalIdentifier animationType:PTRMapAnimationTypeNone completion: ^(PTRMapWidgetError * _Nullable error) {
|
|
33
|
+
NSDictionary *ptrCommand = @{
|
|
34
|
+
@"command": @"site",
|
|
35
|
+
@"siteExternalIdentifier": siteExternalIdentifier,
|
|
36
|
+
@"error": error ? error.errorCode : @""
|
|
37
|
+
};
|
|
38
|
+
[ptrMapWidgetContainerView ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
39
|
+
if (error) {
|
|
40
|
+
NSLog(@"Error showing site: %@", error.errorCode);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
NSLog(@"ready");
|
|
44
|
+
}];
|
|
45
|
+
});
|
|
46
|
+
}];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
RCT_EXPORT_METHOD(building:(nonnull NSNumber*) reactTag siteExternalIdentifier:(NSString*) siteExternalIdentifier buildingExternalIdentifier:(NSString*) buildingExternalIdentifier) {
|
|
50
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
51
|
+
UIView *view = viewRegistry[reactTag];
|
|
52
|
+
if (!view || ![view isKindOfClass:[PTRMapWidgetContainerView class]]) {
|
|
53
|
+
RCTLogError(@"Cannot find PTRMapWidgetContainerView with tag #%@", reactTag);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
NSLog(@"found PTRMapWidgetContainerView");
|
|
57
|
+
PTRMapWidgetContainerView *ptrMapWidgetContainerView = (PTRMapWidgetContainerView *)view;
|
|
58
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
59
|
+
PTRMapWidgetViewController *mapWidget = [ptrMapWidgetContainerView getMapWidget];
|
|
60
|
+
NSLog(@"calling show building method of mapWidget");
|
|
61
|
+
[mapWidget showBuildingWithSiteExternalIdentifier:siteExternalIdentifier buildingExternalIdentifier:buildingExternalIdentifier animationType:PTRMapAnimationTypeNone completion: ^(PTRMapWidgetError * _Nullable error) {
|
|
62
|
+
NSDictionary *ptrCommand = @{
|
|
63
|
+
@"command": @"building",
|
|
64
|
+
@"siteExternalIdentifier": siteExternalIdentifier,
|
|
65
|
+
@"buildingExternalIdentifier": buildingExternalIdentifier,
|
|
66
|
+
@"error": error ? error.errorCode : @""
|
|
67
|
+
};
|
|
68
|
+
[ptrMapWidgetContainerView ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
69
|
+
}];
|
|
70
|
+
});
|
|
71
|
+
}];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
RCT_EXPORT_METHOD(level:(nonnull NSNumber*) reactTag siteExternalIdentifier:(NSString*) siteExternalIdentifier buildingExternalIdentifier:(NSString*) buildingExternalIdentifier levelIndex:(NSInteger) levelIndex) {
|
|
75
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
76
|
+
UIView *view = viewRegistry[reactTag];
|
|
77
|
+
if (!view || ![view isKindOfClass:[PTRMapWidgetContainerView class]]) {
|
|
78
|
+
RCTLogError(@"Cannot find PTRMapWidgetContainerView with tag #%@", reactTag);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
NSLog(@"found PTRMapWidgetContainerView");
|
|
82
|
+
PTRMapWidgetContainerView *ptrMapWidgetContainerView = (PTRMapWidgetContainerView *)view;
|
|
83
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
84
|
+
PTRMapWidgetViewController *mapWidget = [ptrMapWidgetContainerView getMapWidget];
|
|
85
|
+
NSLog(@"calling show level method of mapWidget");
|
|
86
|
+
[mapWidget showLevelWithSiteExternalIdentifier:siteExternalIdentifier buildingExternalIdentifier:buildingExternalIdentifier levelIndex: levelIndex animationType:PTRMapAnimationTypeNone completion: ^(PTRMapWidgetError * _Nullable error) {
|
|
87
|
+
NSDictionary *ptrCommand = @{
|
|
88
|
+
@"command": @"level",
|
|
89
|
+
@"siteExternalIdentifier": siteExternalIdentifier,
|
|
90
|
+
@"buildingExternalIdentifier": buildingExternalIdentifier,
|
|
91
|
+
@"levelIndex": [NSNumber numberWithInteger: levelIndex],
|
|
92
|
+
@"error": error ? error.errorCode : @""
|
|
93
|
+
};
|
|
94
|
+
[ptrMapWidgetContainerView ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
95
|
+
}];
|
|
96
|
+
});
|
|
97
|
+
}];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
RCT_EXPORT_METHOD(poi:(nonnull NSNumber*) reactTag siteExternalIdentifier:(NSString*) siteExternalIdentifier poiExternalIdentifier:(NSString*) poiExternalIdentifier) {
|
|
101
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
102
|
+
UIView *view = viewRegistry[reactTag];
|
|
103
|
+
if (!view || ![view isKindOfClass:[PTRMapWidgetContainerView class]]) {
|
|
104
|
+
RCTLogError(@"Cannot find PTRMapWidgetContainerView with tag #%@", reactTag);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
NSLog(@"found PTRMapWidgetContainerView");
|
|
108
|
+
PTRMapWidgetContainerView *ptrMapWidgetContainerView = (PTRMapWidgetContainerView *)view;
|
|
109
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
110
|
+
PTRMapWidgetViewController *mapWidget = [ptrMapWidgetContainerView getMapWidget];
|
|
111
|
+
NSLog(@"calling show poi method of mapWidget");
|
|
112
|
+
[mapWidget showPoiDetailsWithSiteExternalIdentifier: siteExternalIdentifier poiExternalIdentifier: poiExternalIdentifier animationType:PTRMapAnimationTypeNone completion: ^(PTRMapWidgetError * _Nullable error) {
|
|
113
|
+
NSDictionary *ptrCommand = @{
|
|
114
|
+
@"command": @"poi",
|
|
115
|
+
@"siteExternalIdentifier": siteExternalIdentifier,
|
|
116
|
+
@"poiExternalIdentifier": poiExternalIdentifier,
|
|
117
|
+
@"error": error ? error.errorCode : @""
|
|
118
|
+
};
|
|
119
|
+
[ptrMapWidgetContainerView ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
120
|
+
}];
|
|
121
|
+
});
|
|
122
|
+
}];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
RCT_EXPORT_METHOD(path:(nonnull NSNumber*) reactTag siteExternalIdentifier:(NSString*) siteExternalIdentifier toPoiExternalIdentifier:(NSString*) toPoiExternalIdentifier) {
|
|
126
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
127
|
+
UIView *view = viewRegistry[reactTag];
|
|
128
|
+
if (!view || ![view isKindOfClass:[PTRMapWidgetContainerView class]]) {
|
|
129
|
+
RCTLogError(@"Cannot find PTRMapWidgetContainerView with tag #%@", reactTag);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
NSLog(@"found PTRMapWidgetContainerView");
|
|
133
|
+
PTRMapWidgetContainerView *ptrMapWidgetContainerView = (PTRMapWidgetContainerView *)view;
|
|
134
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
135
|
+
PTRMapWidgetViewController *mapWidget = [ptrMapWidgetContainerView getMapWidget];
|
|
136
|
+
NSLog(@"calling show path method of mapWidget");
|
|
137
|
+
[mapWidget showPathFindingWithSiteExternalIdentifier: siteExternalIdentifier poiExternalIdentifier:toPoiExternalIdentifier animationType:PTRMapAnimationTypeNone completion: ^(PTRMapWidgetError * _Nullable error) {
|
|
138
|
+
NSDictionary *ptrCommand = @{
|
|
139
|
+
@"command": @"path",
|
|
140
|
+
@"siteExternalIdentifier": siteExternalIdentifier,
|
|
141
|
+
@"poiExternalIdentifier": toPoiExternalIdentifier,
|
|
142
|
+
@"error": error ? error.errorCode : @""
|
|
143
|
+
};
|
|
144
|
+
[ptrMapWidgetContainerView ptrMapWidgetDidEndLoadingWithParameters: ptrCommand];
|
|
145
|
+
}];
|
|
146
|
+
});
|
|
147
|
+
}];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
RCT_EXPORT_METHOD(staticPath:(nonnull NSNumber*) reactTag siteExternalIdentifier:(NSString*) siteExternalIdentifier fromPoiExternalIdentifier:(NSString*) fromPoiExternalIdentifier toPoiExternalIdentifier:(NSString*) toPoiExternalIdentifier) {
|
|
151
|
+
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *,UIView *> *viewRegistry) {
|
|
152
|
+
UIView *view = viewRegistry[reactTag];
|
|
153
|
+
if (!view || ![view isKindOfClass:[PTRMapWidgetContainerView class]]) {
|
|
154
|
+
RCTLogError(@"Cannot find PTRMapWidgetContainerView with tag #%@", reactTag);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
NSLog(@"found PTRMapWidgetContainerView");
|
|
158
|
+
PTRMapWidgetContainerView *ptrMapWidgetContainerView = (PTRMapWidgetContainerView *)view;
|
|
159
|
+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
160
|
+
[ptrMapWidgetContainerView showStaticPath: siteExternalIdentifier fromPoiExternalIdentifier: fromPoiExternalIdentifier toPoiExternalIdentifier: toPoiExternalIdentifier];
|
|
161
|
+
});
|
|
162
|
+
}];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@end
|
package/ios/PTRNativeLibrary.h
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PTRNativeLibrary.h
|
|
3
|
-
// pointrSample
|
|
4
|
-
//
|
|
5
|
-
// Created by Furkan Erdem Perşembe on 6.04.2020.
|
|
6
|
-
// Copyright © 2020 Pointr. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import <Foundation/Foundation.h>
|
|
10
2
|
#import <React/RCTBridgeModule.h>
|
|
11
3
|
#import <React/RCTEventEmitter.h>
|
package/ios/PTRNativeLibrary.m
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PTRNativeLibrary.m
|
|
3
|
-
// pointrSample
|
|
4
|
-
//
|
|
5
|
-
// Created by Furkan Erdem Perşembe on 6.04.2020.
|
|
6
|
-
// Copyright © 2020 Pointr. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#import "PTRNativeLibrary.h"
|
|
10
2
|
|
|
11
3
|
#import "react_native_pointr-Swift.h"
|
|
@@ -50,6 +42,10 @@ RCT_EXPORT_MODULE(PTRNativePointrLibrary);
|
|
|
50
42
|
hasListeners = NO;
|
|
51
43
|
}
|
|
52
44
|
|
|
45
|
+
RCT_EXPORT_METHOD(shouldRequestPermissionsAtStartup:(BOOL) shouldRequestPermissionsAtStartup) {
|
|
46
|
+
PointrApp.shouldRequestPermissionsAtStartup = shouldRequestPermissionsAtStartup;
|
|
47
|
+
}
|
|
48
|
+
|
|
53
49
|
RCT_EXPORT_METHOD(initialize:(NSString *)licenseKey baseUrl:(NSString *)baseUrl clientIdentifier:(NSString *)clientIdentifier environment:(NSString *)environment logLevel:(int)logLevel) {
|
|
54
50
|
UIViewController *presentedViewController = RCTPresentedViewController();
|
|
55
51
|
[PointrApp.sharedApp initializeWithLicenseKey:licenseKey baseUrl:baseUrl clientIdentifier:clientIdentifier environment:environment logLevel:logLevel rootViewController:presentedViewController];
|
|
@@ -129,6 +125,10 @@ RCT_EXPORT_METHOD(setPointrMapWidgetConfiguration:(NSString *)string) {
|
|
|
129
125
|
[PointrApp.sharedApp setPointrMapWidgetConfigurationWithString:string];
|
|
130
126
|
}
|
|
131
127
|
|
|
128
|
+
RCT_EXPORT_METHOD(requestPermissions) {
|
|
129
|
+
[PointrApp.sharedApp requestPermissions];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
132
|
#pragma mark Event Manager Delegate
|
|
133
133
|
|
|
134
134
|
- (void)onPositionManagerCalculatedLocationWithLocation:(NSDictionary<NSString *,id> * _Nonnull)location {
|