diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 6136eeb3c..981007df2 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -21,9 +21,9 @@ #import "NSArray+MGLAdditions.h" #import "NSDictionary+MGLAdditions.h" +#import "MGLMapboxEvents.h" #import "MGLMetricsLocationManager.h" - // Returns the path to the default cache database on this system. const std::string &defaultCacheDatabase() { static const std::string path = []() -> std::string { @@ -170,6 +170,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; if (accessToken) { mbglMap->setAccessToken((std::string)[accessToken cStringUsingEncoding:[NSString defaultCStringEncoding]]); + [[MGLMapboxEvents sharedManager] setAccessToken:accessToken]; } } @@ -210,6 +211,17 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; // setup accessibility // self.accessibilityLabel = @"Map"; + + // setup Metrics + MGLMapboxEvents *events = [MGLMapboxEvents sharedManager]; + NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; + NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; + if (appName != nil) { + events.appName = appName; + } + if (appVersion != nil) { + events.appVersion = appVersion; + } // create GL view //