How to easily make a phone call (Cordova)

Stats

1,106 visits, 1,265 views

Translations

This tutorial hasn't been translated.

Tools

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

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