summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLEventsManager.m
blob: f46a3196a6a52bd15c7d0519e573a74a59bb5d59 (plain)
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
#import "MGLEventsManager_Private.h"
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
#import "MGLMapboxEvents.h"
#endif

@implementation MGLEventsManager

+ (instancetype)sharedManager
{
    static dispatch_once_t once;
    static id sharedConfiguration;
    dispatch_once(&once, ^{
        sharedConfiguration = [[self alloc] init];
    });
    return sharedConfiguration;
}

- (void)handleEvent:(NSString *)eventName withAttributes:(NSDictionary *)attributes {
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
    [MGLMapboxEvents pushEvent:eventName withAttributes:attributes];
#endif
    if (self.shouldHandleEvents && self.handler) {
        self.handler(eventName, attributes);
    }
}

@end