How to easily make a phone call (Cordova)

1

Stats

4,288 visits, 5,585 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 18 Oct, 2018. Last updated 19 Feb, 2019

As you may know, Cordova is a tool that allows you to convert your C2/C3 project into a mobile app or game.

There are many paid Cordova plugins out there, but most of them are deprecated.

You can perform the dial action without plugins thought, just using Browser plugin, and adding a plugin to your cordova project.

First of all make an "On Touched object" condition. The action should use the Brower plugin, and choose Execute Javascript. Copy this code, and change XXXXXX with the phone number to call:

" function onSuccess(result){

console.log(result);

}

function onError(result) {

console.log(result);

}

window.plugins.CallNumber.callNumber(onSuccess, onError, 'XXXXXXX', true);"

You will see a boolean variable set to true. If set to true, it will call the number withouit prompting the user to choose an app to perform the call. If set to false, it will make the prompt.

Finally, add this plugin to the project. I use Cordova CLI, so I use this command:

cordova plugin add github.com/Rohfosho/CordovaCallNumberPlugin

But if you use Phonegap or Cocoon just use the corresponding method to add this plugin.

And that´s it!

Please leave a comment if you have any questions.

  • 0 Comments

Want to leave a comment? Login or Register an account!