Here my app deals with phone call.After googling I found the code for calling a user from my app
NSURL *phoneNumber = [[NSURL alloc] initWithString: @"tel:867-5309"];
[[UIApplication sharedApplication] openURL: phoneNumber];
This is my code.I don't know what is going on here, while making a call the device is using any protocols or else the code will initiate the normal dialing function of the device..
Whether itz compulsory to add Core Telephony Framework to my app?
Try this
Where pPhoneNumber is your string phone number..
NSString *deviceName = [UIDevice currentDevice].model;
if([deviceName isEqualToString:@"iPhone"])
{
NSString *strDialedNumber = [pPhoneNumber stringByReplacingOccurrencesOfString:@" " withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",strDialedNumber]]];
}
If you run the code, iOS will make an outgoing call to the specified phone number. iOS uses its native Phone app to make the call.
Note that there should be no special characters in the phone number. It should contain only the numberic digits.
Have a look at the Reference from Apple .
try this:-
NSString *telephoneString=[self.phone stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSMutableString *str1=[[NSMutableString alloc] initWithString:telephoneString];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@"(" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@")" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@"-" withString:@""]];
[str1 setString:[str1 stringByReplacingOccurrencesOfString:@" " withString:@""]];
telephoneString = [@"tel://" stringByAppendingString:str1];
[str1 release];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:telephoneString]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://9016098909891"]];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.