18 March 2020

How to get all contacts and count contact numbers from mobile in cordova?

Get  all contacts and count contact numbers from mobile in cordova.


document.addEventListener("deviceready", jaspreet, false);
function jaspreet() {
   //
   //
   // after deviceready
   //
   //
   navigator.contactsPhoneNumbers.list(function(contacts) {
      console.log(contacts.length + ' contacts found');
  alert(contacts.length);
      for(var i = 0; i < contacts.length; i++) {
         console.log(contacts[i].id + " - " + contacts[i].displayName);
         for(var j = 0; j < contacts[i].phoneNumbers.length; j++) {
            var phone = contacts[i].phoneNumbers[j];
            console.log("===> " + phone.type + "  " + phone.number + " (" + phone.normalizedNumber+ ")");
document.getElementById("names").innerHTML +=phone.type + "  " + phone.number;
         }
      }
   }, function(error) {
      console.error(error);
   });
   


}

No comments:

Post a Comment

How to create youtube videos slider with play and pause option in wordpress?

Create youtube videos slider with play and pause option in wordpress youtube videos slider Use this shortcode:- [punjab_today] function my_...