- (int)simCardNumInPhone { CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init]; if (@available(iOS 12.0, *)) { NSDictionary *ctDict = networkInfo.serviceSubscriberCellularProviders; if ([ctDict allKeys].count > 1) { NSArray *keys = [ctDict allKeys]; CTCarrier *carrier1 = [ctDict objectForKey:[keys firstObject]]; CTCarrier *carrier2 = [ctDict objectForKey:[keys lastObject]]; if (carrier1.mobileCountryCode.length && carrier2.mobileCountryCode.length) { return 2; }else if (!carrier1.mobileCountryCode.length && !carrier2.mobileCountryCode.length) { return 0; }else { return 1; } }else if ([ctDict allKeys].count == 1) { NSArray *keys = [ctDict allKeys]; CTCarrier *carrier1 = [ctDict objectForKey:[keys firstObject]]; if (carrier1.mobileCountryCode.length) { return 1; }else { return 0; } }else { return 0; } }else { CTCarrier *carrier = [networkInfo subscriberCellularProvider]; NSString *carrier_name = carrier.mobileCountryCode; if (carrier_name.length) { return 1; }else { return 0; } } }