Hi,
Is there a way by which we can make a call from within an app or launch an app immediately after the call ends?
I know this is possible because some apps in the app store are already doing this.
Thanks!
Hi,
Is there a way by which we can make a call from within an app or launch an app immediately after the call ends?
I know this is possible because some apps in the app store are already doing this.
Thanks!
if you'd like to make a call from within your app you can use a tel:
url.
Here is a method that takes a telephone number as a string and initiates a call.
- (void)dialNumber: (NSString*)telNumber
{
// fix telNumber NSString
NSArray* telComponents = [telNumber componentsSeparatedByCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
telNumber = [telComponents componentsJoinedByString: @""];
NSString* urlString = [NSString stringWithFormat: @"tel:%@", telNumber];
NSURL* telURL = [NSURL URLWithString: urlString];
//NSLog( @"Attempting to dial %@ with urlString: %@ and URL: %@", telNumber, urlString, telURL );
if ( [[UIApplication sharedApplication] canOpenURL: telURL] )
{
[[UIApplication sharedApplication] openURL: telURL];
}
else
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle: NSLocalizedString( @"Dialer Error", @"" )
message: [NSString stringWithFormat: NSLocalizedString( @"There was a problem dialing %@.", @"" ), telNumber]
delegate: nil
cancelButtonTitle: NSLocalizedString( @"OK", @"" )
otherButtonTitles: nil];
[alert show];
[alert release];
}
}
I think there are two parts to this
In the first case, your UIApplicationDelegate will receive messages application:willChangeStatusBarFrame:
, application:didChangeStatusBarFrame:
, applicationWillResignActive:
, and applicationDidBecomeActive:
all potentially multiple times all depending on if the user elects to answer the call or not, and possibly applicationWillTerminate:
if they choose to leave your application or not. You can also observe these events using the NSNotificationCenter from a class that is not registered as the application delegate, see the "Notifications" section of the UIApplication class reference for details.
In the second case, I do not know there is away with the official SDK to launch your application when a phone call ends. Could you provide a list of the applications that do this?
EDIT:
I think I understand what you mean now. You should follow the advice from @jessecurry, the openURL
on UIApplication
with a tel:
protocol will make a phone call. As to their claim of "doing the impossible" and not quitting the app when the phone call is made, I'm not sure how they did it because I didn't write it. They could be using an external VOIP service like Skype, or simply loading the tel:
URL inside an invisible websheet. Neither of which I can comment on because I haven't tried it.