Hi, @LarsS
Try this:
var options = {
filter : "",
multiple:true,
hasPhoneNumber:true
};
this.contacts.find(["*"],options).then((res) => {
var phoneContactsJson=[];
for (var i = 0; i < contacts.length; i++) {
var contact = contacts[i];
var no =contacts[i].name.formatted;
var phonenumber=contacts[i].phoneNumbers;
if(phonenumber != null) {
for(var n=0;n<phonenumber.length;n++) {
var type=phonenumber[n].type;
if(type=='mobile') {
var phone=phonenumber[n].value;
var mobile;
if(phone.slice(0,1)=='+' || phone.slice(0,1)=='0'){
mobile=phone.replace(/[^a-zA-Z0-9+]/g, "");
}
else {
var mobile_no=phone.replace(/[^a-zA-Z0-9]/g, "");
mobile=countrycode+mobile_no;
}
var contactData={
"name":no,
"number":mobile,
}
phoneContactsJson.push(contactData);
}
}
}
}
phoneContactsJson.sort(function(a, b) {
var nameA = a.name.toUpperCase(); // ignore upper and lowercase
var nameB = b.name.toUpperCase(); // ignore upper and lowercase
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
// names must be equal
return 0;
});
console.log("phoneContactsJson >>>",phoneContactsJson);
}).catch((err) => {
console.log('err',err);
});
Thanks.