// This method will call a phone number from string.
+ (void)callPhoneNumber:(NSString *)phoneNumberString
{
if ([phoneNumberString length]>0)
{
phoneNumberString = [[phoneNumberString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] componentsJoinedByString: @""];
NSString *phoneDecender = @"tel:";
NSString *totalPhoneNumberString = [phoneDecender stringByAppendingString:phoneNumberString];
NSURL *aPhoneNumberURL = [NSURL URLWithString:totalPhoneNumberString];
if ([[UIApplication sharedApplication] canOpenURL:aPhoneNumberURL])
{
[[UIApplication sharedApplication] openURL:aPhoneNumberURL];
}
}
}
+ (void)callPhoneNumber:(NSString *)phoneNumberString
{
if ([phoneNumberString length]>0)
{
phoneNumberString = [[phoneNumberString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] componentsJoinedByString: @""];
NSString *phoneDecender = @"tel:";
NSString *totalPhoneNumberString = [phoneDecender stringByAppendingString:phoneNumberString];
NSURL *aPhoneNumberURL = [NSURL URLWithString:totalPhoneNumberString];
if ([[UIApplication sharedApplication] canOpenURL:aPhoneNumberURL])
{
[[UIApplication sharedApplication] openURL:aPhoneNumberURL];
}
}
}
No comments:
Post a Comment