views:

258

answers:

2

I have an app that worked just fine in version 2.2.1 of the iphone, but have ran into an issue when I upgraded my dev iphone to 3.1.2. Before, dialing a number worked fine, as when the call was ended, my application was loaded. Now, after I hit end call, it loads the default phone application. Does anybody know why this is? I've looked at the diff's from sdk 2.x to 3.x and can't find any reason why this would change. Thanks

+1  A: 

Yes, Apple changed this behavior from 3.0 to 3.1 (I believe, could also be from 2.x to 3.0). They have acknowledged that the change was deliberate and not a bug. There is no workaround that I know of. You just have to live with it a file an enhancement request if you think the old behavior should be made available again.

Ole Begemann
That's what I thought after checking a few forums but just wanted to make sure. Thanks!
developer_7
I just submitted an enhancement request and will follow-up if I hear anything from them.
developer_7
+1  A: 

This was indeed changed from 3.0 to 3.1. If you need the "prompt-for-call" and "relaunch-app-after-call" there are 2 work-arounds:

Option 1: Create a UIWebView and load your tel: URL.

// assuming you have an ivar to store a weak reference to a UIWebView:
// UIWebView *phoneCallWebView;

- (void) dialPhoneNumber:(NSString *)aPhoneNumber
{
    NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",aPhoneNumber]];

    if ( !phoneCallWebView ) {        
        phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];
    }
    [phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]];
}

- (void) dealloc
{
    // cleanup
    [phoneCallWebView release], phoneCallWebView = nil;
    [super dealloc];
}

Option 2: Initiate your call with with the telprompt:<number> URL scheme instead of tel:<number>. Note that this is an undocumented API feature, but it's what UIWebView uses when you tap on a phone number link in a webview (or in MobileSafari). If you are targeting iPhone >= 3.0, there are not any problems using telprompt: (tel: and telprompt: are identical on 3.0). I'm not sure about iPhone OS 2.x.

In general, option 2 works and is easier, but option 1 is actually a "legal" workaround. Unfortunately, there does not seem to be a way to separate the "prompt-for-call" and "relaunch-after-call" behaviors. On iPhoneOS >= 3.1, you can either get both, or neither.

Brian Chapados