开发者

How to initiate a phone call in a web app on iPhone

开发者 https://www.devze.com 2023-03-24 17:47 出处:网络
I want to implement a JavaScript API to initiate phone calls programmatically and without the need for a native Objective-C implementation.

I want to implement a JavaScript API to initiate phone calls programmatically and without the need for a native Objective-C implementation.

What I tried so far was something like location.href='tel:12345';. The result was an error with the message "The URL can’t be shown".

My second attempt was to create a hidden link (like <a href="tel:12345">call</a>) and click it programmatically. This didn't work either, although the link worked when not hidden and clicked manually by the user.

Is it possible to achieve this with JavaScript only or do I need to delegate to the Objective开发者_StackOverflow中文版-C part of the application to initiate the call from there?


Instead of tel:12345 have you tried tel://12345 ?


<a href="tel:1-800-xxx-xxxx">call</a>

Is your url is correct?


Use window.open() for this:

window.open( 'tel:800-888-1234', '_top' );


You will probably have to write the code to do so natively and create a JavaScript function to be called from within the WebView.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号