I'm building an app that lets you call different service centers from Netherlands. The problem is that some of them have a different commercial format (like 0800-xxxx) and the device can't make the call. The code looks like this:
if ([[UIApplication sharedApplication] canOpenURL:phoneURL]) {
[[UIApplication sharedApplication] openURL:phoneURL];
}
Do you have any idea how to format the number or to make the phone call, no matter it's format?
EDIT: This is how the phoneNumber is created:
NSString *phoneNumberString = phoneNumber; // dynamically assigned
NSString *phoneURLString = [NSString stringWithFormat:@"telprompt:%@", phoneNumberString];
NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
Turn Airplane Mode on and off. 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 that Airplane Mode is disabled on your device. If it is disabled but your Android phone still can't make or receive calls, try enabling Airplane Mode and disable it after a couple of seconds. Disable Airplane Mode from Android Quick Settings drawer or navigate to Settings > Network & Internet > Airplane Mode.
If you see a Call Failed message when trying to place a call, the problem could be with your cellular provider or your iPhone. To troubleshoot your iPhone, you can toggle Airplane mode, restart your phone, and reset your SIM card.
I used this code and it worked:
NSString *cleanedString = [[phoneNumber componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""];
NSString *escapedPhoneNumber = [cleanedString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *phoneURLString = [NSString stringWithFormat:@"telprompt:%@", escapedPhoneNumber];
NSURL *phoneURL = [NSURL URLWithString:phoneURLString];
if ([[UIApplication sharedApplication] canOpenURL:phoneURL]) {
[[UIApplication sharedApplication] openURL:phoneURL];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With