简体   繁体   English

检测iPad是否以编程方式支持SIM卡

[英]Detect whether iPad supports sim card programmatically

Currently, I have an app that shows the 3G data / Wifi used by the user since the last reboot. 目前,我有一个应用程序可以显示自上次重启以来用户使用的3G数据/ Wifi。 What I want to do is, if the app is running on an iPad which doesn't support SIM card, I want to hide certain statistics shown to the user. 我想做的是,如果该应用程序在不支持SIM卡的iPad上运行,我想隐藏显示给用户的某些统计信息。

Is it somehow possible to detect whether the current iOS device supports a sim card or not? 是否可以通过某种方式检测当前的iOS设备是否支持sim卡?

As far as I know, you cannot detect if the SIM card is installed. 据我所知,您无法检测到是否已安装SIM卡。 You can only determine if a WWAN connection is available using Reachability or you can use CTCarrier 您只能使用“ 可达性”来确定WWAN连接是否可用,或者可以使用CTCarrier

@import CoreTelephony;

-(BOOL)hasCellularCoverage
{
    CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new];
    CTCarrier *carrier = [networkInfo subscriberCellularProvider];


    if (!carrier.isoCountryCode) {
        NSLog(@"No sim present Or No cellular coverage or phone is on airplane mode.");
        return NO;
    }
    return YES;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM