Contacts模块管理系统通讯录,用于可对系统通讯录进行增、删、改、查等操作。通过plus.contacts获取系统通讯录管理对象。
permissions
"Contacts": {
"description": "访问系统联系人"
}
通讯录对象
interface AddressBook {
function Contact create();
function void find( contactFields, successCB, errorCB, findOptions );
}
通讯录管理对象,可对系统通讯录进行联系人的增、删、改、查操作。
联系人对象
interface Contact {
attribute String displayName;
attribute ContactName name;
attribute String nickname;
attribute ContackField[] phoneNumbers;
attribute ContactField[] emails;
attribute ContactAddress[] addresses;
attribute ContactField[] ims;
attribute ContactOriganization[] organizations;
attribute Date birthday;
attribute String note;
attribute ContactField[] photos;
attribute ContactField[] categories;
attribute ContactField[] urls;
function Contact clone();
function void remove( successCB, errorCB );
function void save( successCB, errorCB );
}
联系人对象,包括联系人的各种信息,如名称、电话号码、地址等。也包括新增、删除联系人的操作方法。
JSON对象,联系人域数据对象
interface ContactField {
attribute String type;
attribute String value;
attribute Boolean preferred;
}
联系人域数据对象,保存联系人特定域信息。
JSON对象,联系人名称对象
interface ContactName {
attribute String formatted;
attribute String familyName;
attribute String givenName;
attribute String middleName;
attribute String honorificPrefix;
attribute String honorificSuffix;
}
联系人名称对象,保存联系人名称信息,如姓、名等。
JSON对象,联系人地址对象
interface ContactAddress {
attribute String type;
attribute String formatted;
attribute String streetAddress;
attribute String locality;
attribute String region;
attribute String country;
attribute String postalCode;
attribute Boolean preferred;
}
联系人地址对象,保存联系人地址信息,如国家、省份、城市等。
JSON对象,联系人所属组织信息
interface ContactOrganization {
attribute String type;
attribute String name;
attribute String department;
attribute String title;
attribute Boolean preferred;
}
JSON对象,查找联系人参数
interface ContactFindOption {
attribute ContactFindFilte[] filter;
attribute Boolean multiple;
}
可设置为空,表示不过滤。
JSON对象,联系人查找过滤器
interface ContactFindFilter {
attribute String logic;
attribute String field;
attribute String value;
}
可取“and”、“or”、“not”,默认值为“and”。
获取通讯录操作成功回调函数
void onSuccess( addressbook ){
// Code AddressBook here
}
查找联系人操作成功回调函数
void onSuccess( contacts ){
// Find contact success.
}
联系人操作成功回调函数
void onSuccess(){
// Operate success
}
联系人操作失败回调
void onError( error ){
// Handle the error
}