Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
refs #3112: cleanups around Core Telephony runtime
Browse files Browse the repository at this point in the history
 - don't do anything with CT in simulator
 - more direct use of dynamic selectors for clarity
  • Loading branch information
incanus committed Dec 3, 2015
1 parent dbe6876 commit e2921f7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions platform/ios/MGLMapboxEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,22 @@ - (instancetype)init {
_scale = [UIScreen mainScreen].scale;
}

#if !TARGET_OS_SIMULATOR
// Collect cellular carrier data if CoreTelephony is linked
Class CTTelephonyNetworkInfo = NSClassFromString(@"CTTelephonyNetworkInfo");
if (CTTelephonyNetworkInfo != NULL) {
id telephonyNetworkInfo = [[CTTelephonyNetworkInfo alloc] init];

Class MGLTelephony = NSClassFromString(@"CTTelephonyNetworkInfo");
if (MGLTelephony) {
id telephonyNetworkInfo = [[MGLTelephony alloc] init];
SEL subscriberCellularProviderSelector = NSSelectorFromString(@"subscriberCellularProvider");
id carrierVendor = ((id (*)(id, SEL))[telephonyNetworkInfo methodForSelector:subscriberCellularProviderSelector])(telephonyNetworkInfo, subscriberCellularProviderSelector);
id carrierVendor = [telephonyNetworkInfo performSelector:subscriberCellularProviderSelector];

// Guard against simulator, iPod Touch, etc.
if (carrierVendor) {
SEL carrierNameSelector = NSSelectorFromString(@"carrierName");
NSString *carrierName = ((id (*)(id, SEL))[carrierVendor methodForSelector:carrierNameSelector])(carrierVendor, carrierNameSelector);
NSString *carrierName = [carrierVendor performSelector:carrierNameSelector];
_carrier = carrierName;
}
}
#endif
}
return self;
}
Expand Down

0 comments on commit e2921f7

Please sign in to comment.