Search code examples
iphonephone-call

iPhone SDK: Launching an app after call ends


How would I 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.


Solution

  • I got this code from Apple site and it works perfectly:

    -(IBAction) dialNumber:(id)sender{
    
    NSString *aPhoneNo = [@"tel://" stringByAppendingString:[itsPhoneNoArray objectAtIndex:[sender tag]]] ; NSURL *url= [NSURL URLWithString:aPhoneNo];
     NSURL  *url= [NSURL URLWithString:aPhoneNo];
    NSString *osVersion = [[UIDevice currentDevice] systemVersion];
    
    if ([osVersion floatValue] >= 3.1) { 
    UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame]; 
    [webview loadRequest:[NSURLRequest requestWithURL:url]]; 
    webview.hidden = YES; 
    // Assume we are in a view controller and have access to self.view 
    [self.view addSubview:webview]; 
    [webview release]; 
    } else { 
    // On 3.0 and below, dial as usual 
    [[UIApplication sharedApplication] openURL: url];
    }
    
    
    }