According to Apple's documentation, in order to make phone call from my app, I need to implement the following protocols:
HTML link:
<a href="tel:1-408-555-5555">1-408-555-5555</a>
Native application URL string:
tel:1-408-555-5555
However, upon completion of a phone call initiated from an HTML link inside a UIWebView, I am redirected right back to my application. But upon completion of a phone call made from a native application URL string, my iphone stays in the iphone's regular phone application, and if I want to return to my application I have to do so manually.
As far as I can tell from reading what others have said, there is no way to change this behavior.
Here is my question:
Android is powered by Chrome. Mobile Safari UIWebView. The UIWebView is different from the ordinary Safari browser, as it is not a stand-alone browser, but merely browser functionality that is embedded in a third party app that allows the app to display content from the web.
The simplest way seems to be:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt:0123456789"]];
You will get a prompt and your app will regain focus after the call is finished.
Behavior does differ between calling -[UIApplication openURL:]
with a tel:
URL, and clicking a link to the same URL in a UIWebView
.
Using a UIWebView
instead of a UILabel might have some downsides, but you don't have to actually display the UIWebView
to get its tel
URL handling behavior. Instead, just load a tel
URL request in an instance of UIWebView without adding it to your view hierarchy.
For example:
#import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface PhoneCaller : NSObject { @private UIWebView *webview; } - (void)callTelURL:(NSURL *)url; @end @implementation - (id)init { self = [super init]; if (self) { webview = [[UIWebView alloc] init]; } return self; } - (void)callTelURL:(NSURL *)url { [webview loadRequest:[NSURLRequest requestWithURL:url]]; } - (void)dealloc { [webview release]; [super dealloc]; } @end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With