plus.contacts.getAddressBook( plus.contacts.ADDRESSBOOK_PHONE, function( addressbook ) {
// 可通过addressbook进行通讯录操作
var contact = addressbook.create();
contact.name = {givenName:"王安"};
contact.phoneNumbers = [{type:"手机",value:"88888888",preferred:true}];
contact.save( function () {
alert( "保存联系人成功" );
}, function ( e ) {
alert( "保存联系人失败:" + e.message );
} );
}, function ( e ) {
alert( "Get address book failed: " + e.message );
} );
用H5+的例子,批量添加到IOS的通讯录会转死闪退,所以想试试原生的效率会不会高一些,但是原生写法不太懂,项目有点着急,求大神帮助!
1 个回复
唱唱 (作者)
找到原因了,IOS给的参数一定要先转字符串
givenName = givenName.toString();
contact.name = {givenName:givenName};
转完后就好了!