javascript PhoneGap:在应用程序内拨打电话

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16634030/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 05:27:29  来源:igfitidea点击:

PhoneGap: Make phone call within application

javascriptcordova

提问by Nick

Is there a way to initiate a phone call within an application using PhoneGap?

有没有办法在使用 PhoneGap 的应用程序中发起电话呼叫?

I know it's possible to use tel:hyperlinks to invoke the dialer, but this means that the application is paused. I'm trying to get this to work from within the application.

我知道可以使用tel:超链接来调用拨号程序,但这意味着应用程序已暂停。我试图让它在应用程序中工作。

Any ideas?

有任何想法吗?

采纳答案by Eliran Malka

You can use the CallNumbercordova plugin (call-numberon npm) to make the actual call.

您可以使用CallNumbercordova 插件(call-number在 npm 上)进行实际调用。

To keep running in the background (when your app is paused due the dialer taking over), there is cordova-plugin-background-mode. As your app will keep running, you can use the success callback passed to the CallNumber API to do stuff when the phone-call has succeeded.

为了保持在后台运行(当您的应用程序由于拨号器接管而暂停时),有cordova-plugin-background-mode。当您的应用程序将继续运行时,您可以使用传递给 CallNumber API 的成功回调在电话成功时执行操作。

回答by Chris Timberlake

PhoneGap/Cordova does not have a JS Function to be able to do what you desire. For Android this requires a special Intent, for iOS it is not possible.

PhoneGap/Cordova 没有 JS 函数可以做你想做的事。对于 Android,这需要一个特殊的 Intent,对于 iOS,这是不可能的。

You will need to create a custom Cordova/PhoneGap plugin using this guide. https://cordova.apache.org/docs/en/4.0.0/guide/hybrid/plugins/

您需要使用本指南创建自定义 Cordova/PhoneGap 插件。https://cordova.apache.org/docs/en/4.0.0/guide/hybrid/plugins/

To achieve the same resolution as this related question. How to make a phone call in android and come back to my activity when the call is done?

达到与此相关问题相同的分辨率。如何在android中拨打电话并在通话结束后返回我的活动?