Skip to content

Apache Cordova, dialer, marcar telefono

Apache Cordova

You didn't specify which version of Cordova you are using so I'm going to assume version > 3.

Make sure that InAppBrowser, a plugin since version 3, is installed and then open the link by calling it through Javascript like this:

window.open('tel:12345678', '_system')

_system will open it with the systems own browser which in turn will open the call dialog, if you use it against http://maps.apple.com/ it will open in the maps app and similar for other apps which opens for special urls.

Remarks:

  • As described in the docs of the InAppBrowser plugin the window.open function won't be set automatically. You have to do it your self: window.open = cordova.InAppBrowser.open;. Instead you can directly use cordova.InAppBrowser.open('tel:12345678', '_system');
  • Make sure your number doesn't have any blankspaces in it (the + prefix is okay). For example you could use a function like the following, assuming num is a string.

Function:

function placeCall(num) {
    if (window.cordova) {
        cordova.InAppBrowser.open('tel:' + num.replace(/\s/g,''), '_system');
    }
}
Simulator doesn't support dialer. No need to waste time.
Continue reading "Apache Cordova, dialer, marcar telefono"

Cordova check if file in url exists

Apache Cordova

 

 

 

Update: Works on iOS too.

Try:

function checkIfFileExists(path){
    // path is the full absolute path to the file.
    window.resolveLocalFileSystemURL(path, fileExists, fileDoesNotExist);
}
function fileExists(fileEntry){
    alert("File " + fileEntry.fullPath + " exists!");
}
function fileDoesNotExist(){
    alert("file does not exist");
}

Found the solution here.

Works on Android. Will test on iOS and update this answer.

Continue reading "Cordova check if file in url exists"