summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-03-23 19:32:34 -0500
committerBrad Leege <bleege@gmail.com>2015-03-23 19:32:34 -0500
commit99049dc6b5872e93db52e1a48fae6ed90e45ecd5 (patch)
tree2573699ee7bf74d40dd2505f4c0e6123bb32a2a6 /platform
parent11aef0d9d097feb98f4f1b9d6060926b0bd4fca6 (diff)
downloadqtlocation-mapboxgl-99049dc6b5872e93db52e1a48fae6ed90e45ecd5.tar.gz
#1033 - Moving map.load to background thread. Moving enabled.push to map.load event. Adding enabled.email check.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLMapView.mm32
1 files changed, 24 insertions, 8 deletions
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];
}
}