4

As title says I'd like to know how to restart my iPhone app after doing this:

[[UIApplication sharedApplication] openURL:[NSURL UrlWithString:@"tel://0123456789"]]

It seems pretty simple as I saw many topics also talking about restoring the very state of the application when openURL is called, but I can't find how to simply restart the app when the calling is finished.

Is it supposed to be the default behavior? As for me, the iPhone opens Favorites after call is finished, I don't know why.

Jukurrpa
  • 4,038
  • 7
  • 43
  • 73
  • This question answers your question in detail. Simply use a uiwebview to place call instead of openURL: http://stackoverflow.com/questions/5317783/return-to-app-behavior-after-phone-call-different-in-native-code-than-uiwebview – Bushra Shahid Sep 26 '11 at 08:34

4 Answers4

4

You can't. Starting an app is solely user's responsibility - which I consider a good thing.

Eiko
  • 25,601
  • 15
  • 56
  • 71
  • Are you sure about that? I don't have it right here but I've already seen an app restarting itself after the call was finished. I didn't know that was possible at that time, and this is what made me search how to do it. – Jukurrpa Jul 23 '10 at 11:04
  • The app will come back if someone calls you, but if the user quits the app for any reason, there is no way to bring it back to front. – Eiko Jul 23 '10 at 11:08
  • And using openURL will necessarily leave the app? Is there any other way to make a phone call without leaving the application? – Jukurrpa Jul 23 '10 at 11:11
  • Making a call brings the phone app to front, thus terminating your app (well, with multitasking it might be suspended instead - but it will hardly make a difference). – Eiko Jul 23 '10 at 11:33
  • Alright I still wonder how did the app I was talking about restarted after the call... Thanks for your answers anyways. – Jukurrpa Jul 23 '10 at 11:36
4

check the discussion here: https://devforums.apple.com/message/128046#128046 create a UIWebView to load the phone url like this:

      UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
      [webview loadRequest:[NSURLRequest requestWithURL:url]];
situee
  • 2,710
  • 2
  • 22
  • 27
3

just use

[[UIApplication sharedApplication] openURL:[NSURL UrlWithString:@"telprompt://0123456789"]]

It will return to the app after call finished

Johnykutty
  • 12,091
  • 13
  • 59
  • 100
1

You can't restart an app after a phone call, as your app has terminated and your code is no longer being run.

If you want to restart after the user visits a webpage, you can put a link with a custom scheme in that webpage, and register it with your app. The user can then tap the link to open your app again.

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104