我的iPhone应用程序无法使用SIM卡检测?

时间:2016-06-23 07:22:40

标签: ios iphone mfmessagecomposeview

我的代码是:

if(![MFMessageComposeViewController canSendText]) {
    UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [warningAlert show];
    return;
}

它可以在模拟器上正常工作,但在没有SIM卡的iPhone中无法正常工作。

1 个答案:

答案 0 :(得分:1)

使用此代码可能会对您有所帮助。

 CTTelephonyNetworkInfo* info = [[CTTelephonyNetworkInfo alloc] init];
    CTCarrier* carrier = info.subscriberCellularProvider;

    if(carrier.mobileNetworkCode == nil || [carrier.mobileNetworkCode isEqualToString:@""])
    {
        NSLog("Not available")
    }else{
        NSLog("available")     
    }