Search code examples
cordovaphonegap-pluginscordova-3cordova-plugins

cordova telephonenumber plugin returns empty string


I'm trying to use the telephonenumber plugin from the following git repository: https://github.com/macdonst/TelephoneNumberPlugin.git and I keep getting an empty string instead of the phone number. there is no error, the success function is called.

I'm using Cordova 3.0, here's the code how I use the plugin:

    var telephoneNumber = cordova.require("cordova/plugin/telephonenumber");
    telephoneNumber.get(function(result) {alert(result);}, function() {alert("FAILED!");});

and yes, I'm calling it after deviceready event :) I even setup a timer that calls it every few seconds, but all I get is empty string as result. any ideas?

thanks!


Solution

  • Not all the phones can return the phone number, in fact, most of them can't.

    Go to settings app, and on the device info there should be a field for the phone number. If the phone number is empty there, there is nothing you can do.