telprompt without alert - ios

My app need to dial a number and I know that telprompt return back to app after dial. But it will alert user every time want to call a number, is there any way to direct call number without show a alert view?

you can make a call using bellow code:-
NSString *value =#"9999999999";//your telnumber
NSURL *url = [[ NSURL alloc ] initWithString:[NSString stringWithFormat:#"tel://%#",value]];
NSLog(#"currunt number%#",url);
[[UIApplication sharedApplication] openURL:url];

hope this will help little more
tel directly call the given number without confirmation and did not return to application after call finishes so instead of it , you may use telprompt.
PhoneNumber=#"999999999";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"telprompt://%#", PhoneNumber]]];

Related

Make a phone call from UIWebView without prompt

SCENARIO
I have an app that is a UIWebView, I make some url overriding for requirements.
PROBLEM
To make a call opening url with tel: works weird in iOS7 and iOS8, it makes the phone call direct in the background, but it also ask for the confirmation, so user experience is horrible:
[[UIApplication sharedApplication] openURL:request.URL];
SOLUTION
To solve this issue, I used telprompt. It works nice in all iOS versions:
NSURL *url = [NSURL URLWithString:#"telprompt://637****"];
return [[UIApplication sharedApplication] openURL:url];
But shows this confirmation dialog:
QUESTION
Now, I have a new requirement, to make the phone call without confirmation or prompt. So... There is some way to make a phone call in iOS omitting the confirmation prompt?
I want something like
NSURL *url = [NSURL URLWithString:#"telnoprompt://637******"];
return [[UIApplication sharedApplication] openURL:url];
NSMutableCharacterSet *characterSet =[NSMutableCharacterSet characterSetWithCharactersInString:#" "];
NSArray *arrayOfComponents = [phone_number componentsSeparatedByCharactersInSet:characterSet];
phone_number = [arrayOfComponents componentsJoinedByString:#""];
NSString *phoneURLString = [NSString stringWithFormat:#"tel:%#", phone_number];
NSString *escapedUrlString = [phoneURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *phoneURL = [NSURL URLWithString:escapedUrlString];

IOS SMS Sending using UI Shared Application

I cannot pass phone number to SMS.
NSString *myString = lblMobilePhone.text;
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[NSString stringWithFormat:#"sms://%#",myString]]];
MFMessageComposeView is how you should be doing it.
If you want to do it your way you need to change it to [NSString stringWithFormat:#"sms:%#",myString] (removed the two // from the url)

How to make a phone call AND return to the original app afterwards

If I use UIWebView to display a phone number and set the data detector type to UIDataDetectorTypePhoneNumber, then when I click on the number its possible to make a phone call.
After the phone call has ended I am returned back to my app.
However if I attempt to programatically invoke the phone app using
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:123456789"]];
or
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://123456789"]];
Then it is not possible to return back to my app after the call has finished.
Is it possible to be able to programmatically launch the phone app and then return back to my app after the call is finished, the same as if the user clicks on a number in a UIWebView?
Instead of:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://123456789"]];
use:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"telprompt://123456789"]];
telprompt:// vs. tel://
This will pop up an alert view and the user will have to tap "call" but this returns to the app after the call is done.
Unfortunately, Apple does not allow this to occur, as when you do the openURL command, it will open that application, and since you cannot access anything within that application, you will have to re-enter your application yourself. You can however save your state in NSUserDefaults, and then have the user be able to go back to the same part of the app as when they left. Check here for help: iOS Human Interface Guidelines
use for instance
NSString * telNummer;
NSString *osVersion = [[UIDevice currentDevice] systemVersion];
if ([osVersion floatValue] >= 5.0) {
telNummer = [NSString stringWithFormat: #"telprompt://%#", person.telephoneNumber];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:telNummer]];
} else {
telNummer = [NSString stringWithFormat: #"tel://%#", person.telephoneNumber];
UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:telNummer]]];
webview.hidden = YES;
// Assume we are in a view controller and have access to self.view
[self.view addSubview:webview];
[webview release];
}
you can send local notification 2-3 seconds after the dial app is visible to the user.
it's not perfect, but clicking on the local notification is and getting back to the original app, its easier the double click on the home button and switch app.
NSURL *url = [NSURL URLWithString:#"telprompt://your phone number"];
[[UIApplication sharedApplication] openURL:url];
This might work?
UIWebView webView = [[UIWebView alloc] init];
NSURL *url = [NSURL URLWithString:#"tel:123456789"];
[webView loadRequest:[NSURLRequest requestWithURL:url]];

launching SMS app when app starts

I need to open the pre installed SMS app in iPhone.
I know how to open SMS app using MFMessageUI class, but the problem is that it can be used to display it as a modal view which in turns requires a view controller.
Does anybody know how to populate it in AppDelegate didFinishLaunchingWithOptions?
Try this code
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"sms:1234567890"]];
NSString *stringURL = #"sms:+12345678901";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
This :)

Making a phone call in an iOS application

I have some code which attempts to make a call within an application, but it doesn't seem to be working:
UIApplication *myApp = [UIApplication sharedApplication];
NSString *theCall = [NSString stringWithFormat:#"tel://%#",phone];
NSLog(#"making call with %#",theCall);
[myApp openURL:[NSURL URLWithString:theCall]];
Sometimes, the variable phone is something such as #"(102) 222-2222". How can I make a call with a phone number like this? Do I need to manually extract the numbers out of it and get rid of all the extra punctuation?
Yup. You need to take those out yourself. Or you can use the snippet below...
NSString *cleanedString = [[phoneNumber componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:#"0123456789-+()"] invertedSet]] componentsJoinedByString:#""];
NSURL *telURL = [NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", cleanedString]];
Note: you may be tempted to use -stringByTrimmingCharactersInSet:, but that one only removes characters at the start and the end of the string, not if they appear in the middle.
To go back to original app you can use telprompt:// instead of tel:// - The tell prompt will prompt the user first, but when the call is finished it will go back to your app:
NSString *phoneNumber = [#"telprompt://" stringByAppendingString:mymobileNO.titleLabel.text];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
just an update on above answer.
Here's a simple method that can be used to make a call and return to the app after the call is finished.
Add the following to your .m file
- (void) dialNumber:(NSString*) number{
number = [#"telprompt://" stringByAppendingString:number];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:number]];
}
Then add the following code wherever you want to make the call from:
[self dialNumber:#"5031234567"];

Resources