我有一个能够发送消息的iPhone应用程序.我想在iphone中没有SIM卡时提醒用户.所以我尝试了以下三个功能来检查SIM卡的可用性
Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
if([messageClass canSendText]){
// Sim available
NSLog(@"Sim available");
}
else{
//Sim not available
NSLog(@"Sim not available");
}
if([MFMessageComposeViewController canSendText]){
// Sim available
NSLog(@"Sim available");
}
else{
//Sim not available
NSLog(@"Sim not available");
}
if([[UIDevice currentDevice].model isEqualToString:@"iPhone"])
{
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:123456"]])
{
NSLog(@"Sim available");
}
else
{
NSLog(@"Sim not available");
}
}
Run Code Online (Sandbox Code Playgroud)
我没有使用SIM卡检查过我的iphone,它总是返回@"Sim available".但是,当我打开默认的"消息"应用程序并尝试发送短信时,它会显示警告"未安装SIM卡"...此消息应用程序如何检测SIM卡可用性?