简体   繁体   English

在html-viewer IOS iPhone中拨打电话号码

[英]Call Telephone Number within a html-viewer IOS iPhone

I need to access an Iphone Function within a html-view. 我需要在html视图中访问Iphone功能。 We created an APP that just shows an html-Mobile-Page via an html-view with a native QR-Code Reader and Push Service. 我们创建了一个应用程序,该应用程序使用本地QR码阅读器和推送服务通过html视图仅显示html-Mobile-Page。

My Problem is that some functions don't work from within an html-viewer: I can't call a phone number 我的问题是,某些功能无法在html查看器中使用:我无法拨打电话号码

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. 在Safari上可以正常使用,但不能在IOS的html-viewer上使用。

With: <a href="#" onclick="prompt('Are you feeling lucky')">Click me</a> 使用: <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. 我无法下载jpgs。 When I click long on an image the iphone in safari opens a "save image"-prompt. 当我长时间单击图像时,Safari中的iPhone会打开“保存图像”提示。 But that doesn't work either on the html-Viewer. 但这在html-viewer上也不起作用。

How can I get it fixed? 我该如何解决? Is there any javascript solution or do I need to modify the html-viewer? 是否有任何javascript解决方案,或者我需要修改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: 您需要tel:超链接,就像在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!). AFAIK UIWebView应该已经正确处理了URI(当然,仅在iPhone上;它不能在iPad或Simulator上运行!)。 I can't test it right now (Simulator won't do), though. 我现在不能测试(模拟器不会)。

But what you can always do is handle the URL yourself. 但是,您始终可以做的就是自己处理URL。 Have your view controller implement the UIWebViewDelegate protocol, set it as delegate to your web view and implement: 让您的视图控制器实现UIWebViewDelegate协议,将其设置为Web视图的委托并实现:

- (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. 再说一次:这仅适用于真实的iPhone。 It will not work on an iPad or Simulator. 它不适用于iPad或模拟器。

尝试类似:

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

Is it an HTML view wrap in a real app? 它是真实应用程序中的HTML视图包装吗? Like with Cordova or some tools like that? 像是Cordova或类似的工具? If so you need to add this in your config file 如果是这样,您需要在配置文件中添加它

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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