0

Is there any way to fetch user's mobile number in phone gap app?

Manish
  • 131
  • 1
  • 1
  • 5
  • It is forbidden on iOS environment as it is written here: http://stackoverflow.com/questions/193182/programmatically-get-own-phone-number-in-iphone-os – noway Sep 24 '12 at 14:29

3 Answers3

1

There is no way you could directly use it in phonegap first you should find how to do this in each platform(ios,android,..) then with phonegap-plugins you could integrate them in your app easily. be aware that this solution is platform base tip: what you are doing is against apple legal Agreement and you will rejected from apple app store if you use that in your application .

Duke
  • 1,731
  • 2
  • 17
  • 33
0

https://github.com/macdonst/TelephoneNumberPlugin

I havnt tried it but i think it works for android devices

0

Try this document

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-contacts/index.html#navigatorcontactspickcontact

This code 100% work fine

function onDeviceReady() {
    // Now safe to use device APIs
    window.addEventListener("batterystatus", onBatteryStatus, false);

    $("#contact").click(function () {
        navigator.contacts.pickContact(function (contact) {

            console.log('The following contact has been selected:' + JSON.stringify(contact));
            $("#contact_details").html('The following contact has been selected:' + JSON.stringify(contact.phoneNumbers));

        }, function (err) {
            console.log('Error: ' + err);
        });
    });

}
yathavan
  • 183
  • 1
  • 14