本文整理汇总了TypeScript中ionic-native.Contacts类的典型用法代码示例。如果您正苦于以下问题:TypeScript Contacts类的具体用法?TypeScript Contacts怎么用?TypeScript Contacts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Contacts类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addContact
addContact(store){
var contact = Contacts.create({
displayName: store.name,
nickname: store.name,
phoneNumbers: [{type: "work", value:store.phone}],
emails: [{type: "work", value:store.email}]
});
contact.birthday = new Date();
contact.save((contact) => { this.nav.present(Alert.create({ title:"Contacto Guardado", message: JSON.stringify(contact) , buttons: ["ok"]}))},(error: Error) => {});
}
示例4: 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');
});
}
示例5: 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();
});
}
示例6: 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();
});
});
}