nyekimov nyekimov - 1 year ago 90
iOS Question

Detect whether device can receive sms

I want to detect if iOS device can receive sms. From first look, I can use the code below:

+(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;


However, my iPad 4 with sim card returns me YES, when by itself it is not able to receive sms. It has iMessage, but for instance I haven't authorized any account in iMessage, so probably I won't receive any sms. How can I detect sms receiving capability and exclude iMessage.

Answer Source

Maybe you can try to detect if iPad can send sms as well, so it should return NO if iMessage not configured. use method canSendText from MFMessageComposeViewController.

check this: https://developer.apple.com/library/ios/Documentation/MessageUI/Reference/MFMessageComposeViewController_class/index.html#//apple_ref/occ/clm/MFMessageComposeViewController/canSendText

Before presenting a message composition view, call the canSendText class method to ensure that the user’s device is appropriately configured. Do not attempt to present a message composition view if the canSendText method returns NO. If neither iMessage nor SMS/MMS (Short Message Service/Multimedia Messaging Service) delivery is available, you can notify the user or simply disable the messaging features in your app.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download