forked from tuanna1601/react-native-indoor-manager
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRNIndoorManager.m
36 lines (30 loc) · 1.21 KB
/
RNIndoorManager.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#import "RNIndoorManager.h"
@implementation RNIndoorManager
RCT_EXPORT_MODULE();
- (NSArray<NSString *> *)supportedEvents
{
return @[@"locationChanged"];
}
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
RCT_EXPORT_METHOD(initService: (NSString *)apiKey apiSecret:(NSString *)apiSecret) {
self.locationManager = [IALocationManager sharedInstance];
self.locationManager.delegate = self;
[self.locationManager setApiKey:apiKey andSecret:apiSecret];
[self.locationManager startUpdatingLocation];
}
- (void)indoorLocationManager:(IALocationManager *)manager didUpdateLocations:(NSArray *)locations
{
(void) manager;
CLLocation *l = [(IALocation *)locations.lastObject location];
IARegion *f = [(IALocation *)locations.lastObject region];
if ([f type] == kIARegionTypeFloorPlan) {
[self sendEventWithName:@"locationChanged" body:@{@"lat": [NSNumber numberWithDouble:l.coordinate.latitude],
@"lng": [NSNumber numberWithDouble:l.coordinate.longitude],
@"atlasId": [f identifier]
}];
}
}
@end