1

i am developing an app in Phonegap for android using html and css, not in native . i need to get the telephone country code of the app user. is there any way to get the telephone country code?? Example: if the user is from INDIA it should get the code :+91 .

Ras
  • 25
  • 2
  • 10

1 Answers1

0

Use these plugins if they help:

Cordova Plugin Globalization

And

Cordova Telephony Plugin

This will return you device telephone number and from here you can extract country code.

Sample:

 var telephoneNumber = cordova.require("cordova/plugin/telephonenumber");
 telephoneNumber.get(function(result) {
        console.log("result = " + result);
    }, function() {
        console.log("error");
 });

EDIT: See this answer.

Community
  • 1
  • 1
Faizan Mubasher
  • 4,427
  • 11
  • 45
  • 81
  • is it any other way that i can get the country code without extracting from the number? i mean when the person uses app it should get the country code. – Ras Feb 20 '15 at 13:43
  • If you have a telephone number, then of course you can extract country code. That's why we are called DEVELOPERS :-) – Faizan Mubasher Feb 20 '15 at 13:45
  • Being a Developer i don't need to get the telephone number and then extract from that.i am not giving the telephone number initially.in most of application we can see the country code will come by default in text area. I AM LOOKING FOR SOMETHING LIKE THAT. :-) – Ras Feb 21 '15 at 04:14
  • the telephone number plugin doesn't work on most devices, only works if you have a SIM card that has the number fixed. To @Ras, no, there is no way to know the telephone contry code. You can know the country if you use geolocation (IP geolocation with a server, or client geolocation with the plugin) – jcesarmobile Feb 23 '15 at 07:44
  • **@ jc esarmobile** using geolocation i need to 'ON' the location services right?? .and mobile does have an IP address ? . – Ras Feb 23 '15 at 11:59