简体   繁体   中英

Call Telephone Number within a html-viewer IOS iPhone

I need to access an Iphone Function within a html-view. We created an APP that just shows an html-Mobile-Page via an html-view with a native QR-Code Reader and Push Service.

My Problem is that some functions don't work from within an html-viewer: I can't call a phone number

I tried:

<a href="callto:00491111111111111">Tel: 0111/1111111111</a>

and:

<a href="tel:00491111111111111" target="_blank">Tel: 0111/1111111111</a>

On Safari it works fine but not on the html-viewer of IOS.

With: <a href="#" onclick="prompt('Are you feeling lucky')">Click me</a>

It opens a prompt - but that is no solution. I need to be able to call the number!

I can't download jpgs. When I click long on an image the iphone in safari opens a "save image"-prompt. But that doesn't work either on the html-Viewer.

How can I get it fixed? Is there any javascript solution or do I need to modify the html-viewer?

thanks in advance! Chris

Try this:

<a href="tel:123456789">Tel: 123456789</a>

I lifted this from my working project.

You need a tel: hyperlink, just like in Safari:

<a href="tel:+004912345">Call me!</a>

AFAIK UIWebView should already handle the URI correctly (of course, only on the iPhone; it cannot work on iPad or Simulator!). I can't test it right now (Simulator won't do), though.

But what you can always do is handle the URL yourself. Have your view controller implement the UIWebViewDelegate protocol, set it as delegate to your web view and implement:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    if ([request.URL.scheme isEqualToString:@"tel"]) {
        // Let an application that can handle "tel:" URIs open
        // the URL (that is: the "phone" app).
        [[UIApplication sharedApplication] openURL:request.URL];
        // We've handled the URL loading ourself.
        return NO;
    }

    // UIWebView should handle it.
    return YES;
}

Again: this will only work on a real iPhone. It will not work on an iPad or Simulator.

尝试类似:

window.location.href = 'tel:+18774506120';

Is it an HTML view wrap in a real app? Like with Cordova or some tools like that? If so you need to add this in your config file

<allow-navigation href="tel:*" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM