views:

274

answers:

1

Hi,

I am trying to make my application that is in the background come to the foreground after a call is disconnected. Here is the code:

if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:0123456789"]]){
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:0123456789"]];
} else {
  // Could not make call
}

CTCallCenter *c=[[CTCallCenter alloc] init];
c.callEventHandler=^(CTCall* call){
  if(call.callState == CTCallStateDisconnected) {
    // code to make app return to the foreground
    // I have tried calling applicationWillEnterForeground, but it didn't work
  }
}

Please help

A: 

I am fairly certain you can't do it with a simple call. Maybe registering a URL handler my app:// and usinng openURL in the completion block could work, but that seems quite hacky.

Joshua Weinberg
I also tried registering a URL handler app://xxx, but it did not work, it did not cause:-(BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url to be executed. But it did work when called from Safari.Thanks