我想检测是否iOS设备可以接收短信。从第一次看,我可以使用下面的代码:检测设备是否可以接收短信
+(bool)canDeviceSendSms {
// Check if the device can send sms
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"sms://"]]) {
// Device supports sms, lets confirm it can place one right now
CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [netInfo subscriberCellularProvider];
NSString *mnc = [carrier mobileNetworkCode];
if (([mnc length] == 0) || ([mnc isEqualToString:@"65535"])) {
// Device cannot send sms at this time. SIM might be removed.
return NO;
} else {
// Device can send sms
return YES;
}
} else {
// Device does not support sms sending
return NO;
}
}
然而,我的iPad 4的SIM卡返回我是的,当它本身是不能接收短信。它有iMessage,但例如我没有授权iMessage中的任何帐户,所以可能我不会收到任何短信。我如何检测短信接收能力并排除iMessage。
返回YES有当u可以检查其中的iPhone或iPad – 2014-11-24 15:23:34