From 99049dc6b5872e93db52e1a48fae6ed90e45ecd5 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Mon, 23 Mar 2015 19:32:34 -0500 Subject: #1033 - Moving map.load to background thread. Moving enabled.push to map.load event. Adding enabled.email check. --- platform/ios/MGLMapView.mm | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'platform') diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 6f30b7b818..000e639563 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -388,12 +388,30 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; _regionChangeDelegateQueue.maxConcurrentOperationCount = 1; - // Fire map.load - NSMutableDictionary *evt = [[NSMutableDictionary alloc] init]; - [evt setValue:[[NSNumber alloc] initWithDouble:mbglMap->getLatLng().latitude] forKey:@"lat"]; - [evt setValue:[[NSNumber alloc] initWithDouble:mbglMap->getLatLng().longitude] forKey:@"lng"]; - [evt setValue:[[NSNumber alloc] initWithDouble:mbglMap->getZoom()] forKey:@"zoom"]; - [[MGLMapboxEvents sharedManager] pushEvent:@"map.load" withAttributes:evt]; + // Fire map.load on a background thread + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + + NSMutableDictionary *evt = [[NSMutableDictionary alloc] init]; + [evt setValue:[[NSNumber alloc] initWithDouble:mbglMap->getLatLng().latitude] forKey:@"lat"]; + [evt setValue:[[NSNumber alloc] initWithDouble:mbglMap->getLatLng().longitude] forKey:@"lng"]; + [evt setValue:[[NSNumber alloc] initWithDouble:mbglMap->getZoom()] forKey:@"zoom"]; + [[MGLMapboxEvents sharedManager] pushEvent:@"map.load" withAttributes:evt]; + + [evt setValue:[[NSNumber alloc] initWithBool:[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]] forKey:@"enabled.push"]; + + NSString *email = @"Unknown"; + Class MFMailComposeViewController = NSClassFromString(@"MFMailComposeViewController"); + if (MFMailComposeViewController) { + SEL canSendMail = NSSelectorFromString(@"canSendMail"); + BOOL sendMail = ((BOOL (*)(id, SEL))[MFMailComposeViewController methodForSelector:canSendMail])(MFMailComposeViewController, canSendMail); + email = [NSString stringWithFormat:@"%i", sendMail]; + } + [evt setValue:email forKey:@"enabled.email"]; + + + + + }); return YES; } @@ -668,8 +686,6 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; [dict setValue:[[NSNumber alloc] initWithDouble:coord.longitude] forKey:@"lng"]; [dict setValue:[[NSNumber alloc] initWithDouble:[self zoomLevel]] forKey:@"zoom"]; - [dict setValue:[[NSNumber alloc] initWithBool:[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]] forKey:@"enabled.push"]; - [[MGLMapboxEvents sharedManager] pushEvent:@"map.dragend" withAttributes:dict]; } } -- cgit v1.2.1