由于app是用的外包公司做的,所以我们想做一个h5页面满足自己的需求,达到少量的金钱,但是在ios系统app上面使用a
标签或window.location.href拨打电话都不行,但是在ios浏览器上是可以进行拨打的,请问这是什么原因啊?有没有什么解决办法
HTML的头部要添加一个meta文件
<meta name="format-detection" content="telephone=yes"/>
然后a标签href添加tel:
<a href="tel:xxxxxxxxxxx"></a>
你好是这样的,在苹果浏览器可以,但是ios app不行,没反应
@菜鸟wl: 我刚才测试了一下, 用UIWebView是可以直接弹出拨打电话弹框的, wkwebview确实不行.
WKWebView还需要添加一个navigationDelegate代理方法
@interface TestViewController ()<WKNavigationDelegate>
@end
@implementation TestViewController
{
WKWebView *wkWebView;
}
(void)viewDidLoad {
[super viewDidLoad];
wkWebView = [[WKWebView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:wkWebView];
wkWebView.navigationDelegate = self;
NSURL url = [NSURL URLWithString:@"https://www.xxx.xxx"];
NSURLRequest request = [NSURLRequest requestWithURL:url];
[wkWebView loadRequest:request];
}
(void)webView:(WKWebView )webView decidePolicyForNavigationAction:(WKNavigationAction )navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
NSURL URL = navigationAction.request.URL;
NSString scheme = [URL scheme];
if ([scheme isEqualToString:@"tel"]) {
NSString resourceSpecifier = [URL resourceSpecifier];
NSString callPhone = [NSString stringWithFormat:@"telprompt://%@", resourceSpecifier];
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
});
}
decisionHandler(WKNavigationActionPolicyAllow);
}
@end
@菜鸟wl: