summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-03-26 22:10:26 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-03-26 22:10:26 -0700
commite42dab756cd86042afea2f883e5f465e202ca694 (patch)
treee57e25710973cd18aeeccd5b96954aa8e766fa56
parent00d2cbe5cbab789388d3b06b899d007b2c44e61a (diff)
parentc4d19203b7fa80177af0f1bf6ad0647e539b7b45 (diff)
downloadqtlocation-mapboxgl-e42dab756cd86042afea2f883e5f465e202ca694.tar.gz
Merge pull request #1131 from friedbunny/remote-notifications-ios7
Metrics: Remote-notifications-enabled support for iOS 7
-rw-r--r--platform/ios/MGLMapView.mm21
1 files changed, 17 insertions, 4 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index a4604bc580..dd04b7c467 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -365,10 +365,23 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 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"];
- [evt setValue:[[NSNumber alloc] initWithBool:[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]] forKey:@"enabled.push"];
+ [evt setValue:@(mbglMap->getLatLng().latitude) forKey:@"lat"];
+ [evt setValue:@(mbglMap->getLatLng().longitude) forKey:@"lng"];
+ [evt setValue:@(mbglMap->getZoom()) forKey:@"zoom"];
+
+ BOOL isRegisteredForRemoteNotifications;
+ if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
+ // iOS 8+
+ isRegisteredForRemoteNotifications = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
+ } else {
+ // iOS 7
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
+ isRegisteredForRemoteNotifications = (types == UIRemoteNotificationTypeNone) ? NO : YES;
+ #pragma clang diagnostic pop
+ }
+ [evt setValue:@(isRegisteredForRemoteNotifications) forKey:@"enabled.push"];
NSString *email = @"Unknown";
Class MFMailComposeViewController = NSClassFromString(@"MFMailComposeViewController");