Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if device can make a phone call (iOS 8)?

On iOS <8 you could use function - (BOOL)canOpenURL:(NSURL *)url.

On iOS 8 this function returns YES, even on iPad. I guess it's connected with calling over wi-fi (or another new functionality), but my iPad cannot make phone calls. Anyone know better way to detect that capability?

like image 718
Maciej Kozieł Avatar asked Sep 16 '14 15:09

Maciej Kozieł


People also ask

Why can't I make phone calls on my iPhone 8?

Go to Settings and turn on Airplane Mode, wait five seconds, then turn it off. Check Do Not Disturb. Go to Settings > Focus > Do Not Disturb and make sure it's off. Check for any blocked phone numbers.

How do I know if my iPad can make phone calls?

On your iPad or iPod touch: Go to Settings > FaceTime, then turn on FaceTime and Calls from iPhone. If you're asked, turn on Wi-Fi Calling. On your Mac: Open FaceTime, choose FaceTime > Preferences > Settings, then select Calls from iPhone.

Where is calls on other devices on iPhone 8?

On your iPhone, go to Settings > Phone > Calls on Other Devices, then turn on Allow Calls on Other Devices. It says FaceTime and iCloud must be signed in to the same Apple ID to enable calls on other devices.


1 Answers

Ok, so I just encountered the same problem. Seems like iPad and iPod return YES value for canOpenURL method. Please see my answer below since this worked for me. I had a custom collection view cell and that is why had this code in my awakeFromNib file. However, you should write this code in ViewDidLoad of that perticular viewController.

Make sure to include "CoreTelephony.Framework" in your project.

Include below files in the view controller:

 #import <CoreTelephony/CTTelephonyNetworkInfo.h>  #import <CoreTelephony/CTCarrier.h>      - (void)awakeFromNib {     // Initialization code      if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]]) {         // Check if iOS Device supports phone calls         CTTelephonyNetworkInfo *netInfo = [[CTTelephonyNetworkInfo alloc] init];         CTCarrier *carrier = [netInfo subscriberCellularProvider];         NSString *mnc = [carrier mobileNetworkCode];         // User will get an alert error when they will try to make a phone call in airplane mode.         if (([mnc length] == 0)) {             // Device cannot place a call at this time.  SIM might be removed.         } else {             // iOS Device is capable for making calls         }     } else {         // iOS Device is not capable for making calls     }        if ( ! [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"sms:"]]) {        // iOS Device is not capable to send SMS messages.      } } 
like image 118
Milan Shah Avatar answered Sep 23 '22 04:09

Milan Shah