本文整理汇总了TypeScript中ionic-native.Contacts.find方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Contacts.find方法的具体用法?TypeScript Contacts.find怎么用?TypeScript Contacts.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ionic-native.Contacts
的用法示例。
在下文中一共展示了Contacts.find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getContacts
getContacts(state: number) {
if (state == 0) {
let loading = this.loadingCtrl.create({
spinner: 'crescent',
content: this.lgnUsed.loader_config,
duration: 10000
});
loading.present();
}
Contacts.find(['phoneNumbers', 'displayName'], { multiple: true, hasPhoneNumber: true, desiredFields: ['phoneNumbers', 'displayName'] })
.then((contacts) => {
let contactsList;
contactsList = contacts;
this.setPermissionCache(true);
this.formatPhoneNumbers(contactsList);
},
(err) => {
if (err) {
console.log(err);
err >= 0 && err <= 20 ? this.setPermissionCache(false) : null;
}
});
}
示例2: getContacts
getContacts() {
Contacts.find(["*"]).then((contact) => {
console.log(contact)
}, (err) => {
console.log(err)
})
}
示例3: ionViewDidLoad
ionViewDidLoad() {
Contacts.find(['displayName'], {
filter: this.node.name,
multiple: true,
desiredFields: ['name', 'displayName', 'photos', 'birthday', 'phoneNumbers'],
hasPhoneNumber: true
})
.then((contacts) => {
if (contacts) {
this.contacts.push.apply(this.contacts, contacts);
this.backService.trackAction('contacts', 'ok');
}
}, () => {
this.backService.trackAction('contacts', 'error');
});
}
示例4: fixContacts
fixContacts() {
let fixed = 0;
console.log('ok so wtf');
Contacts.find(["name"]).then((res) => {
//console.log(res);
res.forEach( (contact:Contact) => {
if(!contact.photos) {
console.log('FIXING '+contact.name.formatted);
console.log(contact);
var f = new ContactField('url',this.randomCat(),true);
contact.photos = [];
contact.photos.push(f);
contact.save();
fixed++;
}
});
let subTitle, button;
if(fixed === 0) {
subTitle = "Sorry, but every single one of your contacts had a picture. I did nothing.";
button = "Sad Face";
} else {
subTitle = `I've updated ${fixed} contact(s). Enjoy!`;
button = "Awesome";
}
this.alertCtrl.create({
title:'Contacts Updated',
subTitle:subTitle,
buttons:[button]
}).present();
});
}
示例5: fixContacts
fixContacts() {
let loader = this.loadingCtrl.create({
content: "Doing important work...",
});
loader.present();
let fixed = 0;
let proms = [];
Contacts.find(["name"]).then((res) => {
res.forEach( (contact:Contact) => {
if(!contact.photos) {
console.log('FIXING '+contact.name.formatted);
//console.log(contact);
proms.push(new Promise( (resolve, reject) => {
this.toDataUrl(this.randomCat(), function(s) {
var f = new ContactField('base64',s,true);
contact.photos = [];
contact.photos.push(f);
console.log('FIXED '+contact.name.formatted);
contact.save();
fixed++;
resolve();
});
}));
}
});
Promise.all(proms).then( (res) => {
loader.dismissAll();
console.log('all done, fixed is '+fixed);
let subTitle, button;
if(fixed === 0) {
subTitle = "Sorry, but every single one of your contacts had a picture. I did nothing.";
button = "Sad Face";
} else {
subTitle = `I've updated ${fixed} contact(s). Enjoy!`;
button = "Awesome";
}
this.alertCtrl.create({
title:'Contacts Updated',
subTitle:subTitle,
buttons:[button]
}).present();
});
});
}