summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wray <jason@kulturny.com>2015-10-09 14:44:06 -0400
committerJason Wray <jason@kulturny.com>2015-10-19 13:52:28 -0400
commit28be82c1c19505abb47ca1c03fd069cc4a015ec6 (patch)
treea948b97341e1e7ac423a744fb0f8c985314de070
parentaaf090b87dbc96f7a09e783833c10d0b88a16d39 (diff)
downloadqtlocation-mapboxgl-28be82c1c19505abb47ca1c03fd069cc4a015ec6.tar.gz
[ios] remove CoreTelephony dependency
Cellular carrier name and connectivity level will now only be sent if the developer independently chooses to link the CoreTelephony framework in their app.
-rw-r--r--CHANGELOG.md1
-rw-r--r--INSTALL.md6
-rw-r--r--gyp/platform-ios.gypi1
-rw-r--r--ios/Mapbox-iOS-SDK.podspec2
-rw-r--r--platform/ios/MGLMapboxEvents.m66
-rw-r--r--test/ios/ios-tests.xcodeproj/project.pbxproj2
6 files changed, 37 insertions, 41 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dbc795ada0..e16d11f182 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
- Fixed a rendering issue with styles that use the `background-pattern` property. ([#2531](https://github.com/mapbox/mapbox-gl-native/pull/2531))
- Labels can now line wrap on hyphens and other punctuation. ([#2598](https://github.com/mapbox/mapbox-gl-native/pull/2598))
- A new delegate callback was added for observing taps to annotation callout views. ([#2596](https://github.com/mapbox/mapbox-gl-native/pull/2596))
+- Removed CoreTelephony.framework dependency. ([#2581](https://github.com/mapbox/mapbox-gl-native/pull/2581))
## iOS 2.1.2
diff --git a/INSTALL.md b/INSTALL.md
index cb72c55a98..17ad27665e 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -150,7 +150,6 @@ Currently, until [#1437](https://github.com/mapbox/mapbox-gl-native/issues/1437)
1. Add the following Cocoa framework dependencies to your target's *Link Binary With Libraries* build phase:
- - `CoreTelephony.framework`
- `GLKit.framework`
- `ImageIO.framework`
- `MobileCoreServices.framework`
@@ -159,6 +158,7 @@ Currently, until [#1437](https://github.com/mapbox/mapbox-gl-native/issues/1437)
- `libc++.dylib`
- `libsqlite3.dylib`
- `libz.dylib`
+ - `CoreTelephony.framework` (optional, telemetry-only)
1. Add `-ObjC` to your target's "Other Linker Flags" build setting (`OTHER_LDFLAGS`).
@@ -168,6 +168,10 @@ Devices: iPhone 4S and above (5, 5c, 5s, 6, 6 Plus), iPad 2 and above (3, 4, Min
iOS: 7.0+
+### Telemetry
+
+The iOS SDK collects [telemetry data](https://www.mapbox.com/telemetry/) during use and [requires additional setup](https://www.mapbox.com/ios-sdk/#metrics_opt_out).
+
## Linux
diff --git a/gyp/platform-ios.gypi b/gyp/platform-ios.gypi
index 87c4e684c6..87cecb5e77 100644
--- a/gyp/platform-ios.gypi
+++ b/gyp/platform-ios.gypi
@@ -75,7 +75,6 @@
],
'ldflags': [
'-framework CoreLocation',
- '-framework CoreTelephony',
'-framework GLKit',
'-framework ImageIO',
'-framework MobileCoreServices',
diff --git a/ios/Mapbox-iOS-SDK.podspec b/ios/Mapbox-iOS-SDK.podspec
index c9d84a1681..c70bf8ff57 100644
--- a/ios/Mapbox-iOS-SDK.podspec
+++ b/ios/Mapbox-iOS-SDK.podspec
@@ -28,7 +28,7 @@ Pod::Spec.new do |m|
m.vendored_library = 'libMapbox.a'
m.module_name = 'Mapbox'
- m.frameworks = 'CoreLocation', 'CoreTelephony', 'GLKit', 'ImageIO', 'MobileCoreServices', 'QuartzCore', 'SystemConfiguration'
+ m.frameworks = 'CoreLocation', 'GLKit', 'ImageIO', 'MobileCoreServices', 'QuartzCore', 'SystemConfiguration'
m.libraries = 'c++', 'sqlite3', 'z'
m.xcconfig = {
'OTHER_CPLUSPLUSFLAGS' => '-std=gnu++11 -stdlib=libc++',
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index 1bddb7ff40..bc6dfb02b7 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -1,8 +1,6 @@
#import "MGLMapboxEvents.h"
#import <UIKit/UIKit.h>
-#import <CoreTelephony/CTTelephonyNetworkInfo.h>
-#import <CoreTelephony/CTCarrier.h>
#import <CoreLocation/CoreLocation.h>
#include <mbgl/platform/darwin/reachability.h>
@@ -77,8 +75,19 @@ const NSTimeInterval MGLFlushInterval = 60;
} else {
_scale = [UIScreen mainScreen].scale;
}
- CTCarrier *carrierVendor = [[[CTTelephonyNetworkInfo alloc] init] subscriberCellularProvider];
- _carrier = [carrierVendor carrierName];
+
+ // Collect cellular carrier data if CoreTelephony is linked
+ Class CTTelephonyNetworkInfo = NSClassFromString(@"CTTelephonyNetworkInfo");
+ if (CTTelephonyNetworkInfo) {
+ id telephonyNetworkInfo = [[CTTelephonyNetworkInfo alloc] init];
+
+ SEL subscriberCellularProviderSelector = NSSelectorFromString(@"subscriberCellularProvider");
+ id carrierVendor = ((id (*)(id, SEL))[telephonyNetworkInfo methodForSelector:subscriberCellularProviderSelector])(telephonyNetworkInfo, subscriberCellularProviderSelector);
+
+ SEL carrierNameSelector = NSSelectorFromString(@"carrierName");
+ NSString *carrierName = ((id (*)(id, SEL))[carrierVendor methodForSelector:carrierNameSelector])(carrierVendor, carrierNameSelector);
+ _carrier = carrierName;
+ }
}
return self;
}
@@ -497,14 +506,13 @@ const NSTimeInterval MGLFlushInterval = 60;
[evt setValue:@((int)(100 * [UIDevice currentDevice].batteryLevel)) forKey:@"batteryLevel"];
[evt setValue:@(strongSelf.data.scale) forKey:@"resolution"];
[evt setValue:strongSelf.data.carrier forKey:@"carrier"];
-
- NSString *cell = [strongSelf currentCellularNetworkConnectionType];
- if (cell) {
- [evt setValue:cell forKey:@"cellularNetworkType"];
- } else {
- [evt setObject:[NSNull null] forKey:@"cellularNetworkType"];
+
+ NSString *cell;
+ if (strongSelf.data.carrier) {
+ cell = [strongSelf currentCellularNetworkConnectionType];
}
-
+ [evt setObject:(cell ? cell : [NSNull null]) forKey:@"cellularNetworkType"];
+
MGLReachability *reachability = [MGLReachability reachabilityForLocalWiFi];
[evt setValue:([reachability isReachableViaWiFi] ? @YES : @NO) forKey:@"wifi"];
@@ -716,33 +724,19 @@ const NSTimeInterval MGLFlushInterval = 60;
// Can be called from any thread.
//
- (NSString *) currentCellularNetworkConnectionType {
- CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
- NSString *radioTech = telephonyInfo.currentRadioAccessTechnology;
-
+ NSString *radioTech;
+
+ Class CTTelephonyNetworkInfo = NSClassFromString(@"CTTelephonyNetworkInfo");
+ if (CTTelephonyNetworkInfo) {
+ id telephonyNetworkInfo = [[CTTelephonyNetworkInfo alloc] init];
+ SEL currentRadioAccessTechnologySelector = NSSelectorFromString(@"currentRadioAccessTechnology");
+ radioTech = ((id (*)(id, SEL))[telephonyNetworkInfo methodForSelector:currentRadioAccessTechnologySelector])(telephonyNetworkInfo, currentRadioAccessTechnologySelector);
+ }
+
if (radioTech == nil) {
return nil;
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyGPRS]) {
- return @"GPRS";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyEdge]) {
- return @"EDGE";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyWCDMA]) {
- return @"WCDMA";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyHSDPA]) {
- return @"HSDPA";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyHSUPA]) {
- return @"HSUPA";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyCDMA1x]) {
- return @"CDMA1x";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0]) {
- return @"CDMAEVDORev0";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA]) {
- return @"CDMAEVDORevA";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB]) {
- return @"CDMAEVDORevB";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyeHRPD]) {
- return @"HRPD";
- } else if ([radioTech isEqualToString:CTRadioAccessTechnologyLTE]) {
- return @"LTE";
+ } else if ([radioTech hasPrefix:@"CTRadioAccessTechnology"]) {
+ return [radioTech substringFromIndex:23];
} else {
return @"Unknown";
}
diff --git a/test/ios/ios-tests.xcodeproj/project.pbxproj b/test/ios/ios-tests.xcodeproj/project.pbxproj
index fed45bf7ed..c5f2264dd9 100644
--- a/test/ios/ios-tests.xcodeproj/project.pbxproj
+++ b/test/ios/ios-tests.xcodeproj/project.pbxproj
@@ -25,7 +25,6 @@
DD0E6F9B1B01B68E00DC035A /* OHHTTPStubsResponse+HTTPMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = DD0E6F931B01B68E00DC035A /* OHHTTPStubsResponse+HTTPMessage.m */; };
DD0E6F9C1B01B68E00DC035A /* OHHTTPStubsResponse+JSON.m in Sources */ = {isa = PBXBuildFile; fileRef = DD0E6F951B01B68E00DC035A /* OHHTTPStubsResponse+JSON.m */; };
DD0E6F9D1B01B68E00DC035A /* OHPathHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = DD0E6F971B01B68E00DC035A /* OHPathHelpers.m */; };
- DD41CE091ACB5DBC00FA7979 /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41CE081ACB5DBC00FA7979 /* CoreTelephony.framework */; };
DD41CE0B1ACB5DC400FA7979 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41CE0A1ACB5DC400FA7979 /* SystemConfiguration.framework */; };
DD41CE0D1ACB5DCB00FA7979 /* libc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41CE0C1ACB5DCB00FA7979 /* libc++.dylib */; };
DD41CE0F1ACB5DD000FA7979 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DD41CE0E1ACB5DD000FA7979 /* libsqlite3.dylib */; };
@@ -145,7 +144,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- DD41CE091ACB5DBC00FA7979 /* CoreTelephony.framework in Frameworks */,
DD41CE171ACB5DE700FA7979 /* GLKit.framework in Frameworks */,
DD41CE151ACB5DE000FA7979 /* ImageIO.framework in Frameworks */,
DD41CE131ACB5DDA00FA7979 /* MobileCoreServices.framework in Frameworks */,