0

How can you execute code after the phone call is made? My app makes a phone call with the following code:

- (void)callTelURL:(NSURL *)url
{
    UIWebView  *webview = [[UIWebView alloc] init];
    [self.view addSubview:webview];

    [webview loadRequest:[NSURLRequest requestWithURL:url]]; 
    [webview release];
}

I immediately get applicationWillResignActive, applicationDidBecomeActive and applicationDidEnterBackground but I never get applicationWillEnterForeground or applicationDidBecomeActive once the phone call has completed and I am back in my application. Is there something I can do to be notified when I have returned from my call so I can execute some code?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Joel Parker
  • 295
  • 1
  • 4
  • 17
  • possible duplicate of [Return to app behavior after phone call different in native code than UIWebView](http://stackoverflow.com/questions/5317783/return-to-app-behavior-after-phone-call-different-in-native-code-than-uiwebview) – jscs Jun 10 '12 at 22:32
  • I had looked at that post. It shows how to return to your application but doesn't tell where you can execute code after returning. The thing that is stumping is me is that I am not getting the applicationWillEnterForeground event like I was expecting. – Joel Parker Jun 10 '12 at 22:56

1 Answers1

0

You won't get a call to applicationWillEnterForeground if your app is in the foreground when a call comes in and then the call is dismissed.

http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html

So execute the code in applicationDidBecomeActive but only when the preceeding call was applicationWillresignActive.

P.S. Just because your app gets a applicationWillResignActive then applicationDidBecomeActive does not necessarily mean you got a phone call, other things could cause this too. So you cannot rely on this if you want to execute code after only a phone call has caused this behaviour and nothing else

Gruntcakes
  • 37,738
  • 44
  • 184
  • 378