2020#if __has_include("CoreTelephony/CTTelephonyNetworkInfo.h") && !TARGET_OS_MACCATALYST && \
2121 !TARGET_OS_OSX && !TARGET_OS_TV && !TARGET_OS_WATCH
2222#define TARGET_HAS_MOBILE_CONNECTIVITY
23- #import < CoreTelephony/CTCarrier.h>
2423#import < CoreTelephony/CTTelephonyNetworkInfo.h>
2524#import < SystemConfiguration/SystemConfiguration.h>
2625#endif
@@ -38,61 +37,6 @@ + (CTTelephonyNetworkInfo *)getNetworkInfo {
3837}
3938#endif
4039
41- + (NSString *_Nullable)getNetworkMobileCountryCode {
42- #ifdef TARGET_HAS_MOBILE_CONNECTIVITY
43- CTTelephonyNetworkInfo *networkInfo = [GULNetworkInfo getNetworkInfo ];
44- #pragma clang diagnostic push
45- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
46- CTCarrier *provider = networkInfo.subscriberCellularProvider ;
47- #pragma clang diagnostic push
48- return provider.mobileCountryCode ;
49- #endif
50- return nil ;
51- }
52-
53- + (NSString *_Nullable)getNetworkMobileNetworkCode {
54- #ifdef TARGET_HAS_MOBILE_CONNECTIVITY
55- CTTelephonyNetworkInfo *networkInfo = [GULNetworkInfo getNetworkInfo ];
56- #pragma clang diagnostic push
57- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
58- CTCarrier *provider = networkInfo.subscriberCellularProvider ;
59- #pragma clang diagnostic push
60- return provider.mobileNetworkCode ;
61- #endif
62- return nil ;
63- }
64-
65- /* *
66- * Returns the formatted MccMnc if the inputs are valid, otherwise nil
67- * @param mcc The Mobile Country Code returned from `getNetworkMobileCountryCode`
68- * @param mnc The Mobile Network Code returned from `getNetworkMobileNetworkCode`
69- * @returns A string with the concatenated mccMnc if both inputs are valid, otherwise nil
70- */
71- + (NSString *_Nullable)formatMcc : (NSString *)mcc andMNC : (NSString *)mnc {
72- // These are both nil if the target does not support mobile connectivity
73- if (mcc == nil && mnc == nil ) {
74- return nil ;
75- }
76-
77- if (mcc.length != 3 || mnc.length < 2 || mnc.length > 3 ) {
78- return nil ;
79- }
80-
81- // If the resulting appended mcc + mnc contains characters that are not
82- // decimal digits, return nil
83- static NSCharacterSet *notDigits;
84- static dispatch_once_t token;
85- dispatch_once (&token, ^{
86- notDigits = [[NSCharacterSet decimalDigitCharacterSet ] invertedSet ];
87- });
88- NSString *mccMnc = [mcc stringByAppendingString: mnc];
89- if ([mccMnc rangeOfCharacterFromSet: notDigits].location != NSNotFound ) {
90- return nil ;
91- }
92-
93- return mccMnc;
94- }
95-
9640+ (GULNetworkType)getNetworkType {
9741 GULNetworkType networkType = GULNetworkTypeNone;
9842
0 commit comments