Interface ContactManager
contact 모듈의 관리자 인터페이스입니다.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
contact 모듈의 관리자 인터페이스입니다. |
Method Summary
Interface Detail
ContactManager()
contact 모듈의 관리자 인터페이스입니다. 이 인터페이스는 주소록을 얻을 수 있는 함수를 제공합니다. 주소록에 대한 참조를 얻은 후에는 연락처를 추가, 삭제, 갱신할 수 있습니다.
Method Detail
-
{PendingOperation} getAddressBooks(successCallback, errorCallback)
이용 가능한 주소록을 얻습니다.
이 함수가 성공하면 사용 가능한 주소록 객체들의 배열을 매개변수로 successCallback 함수가 호출됩니다. 사용 가능한 주소록이 존재하지 않으면 빈 배열이 전달됩니다.
주소록을 얻는 데 실패하면 오류의 원인을 설명하는 DeviceAPIError 객체를 매개변수로 하여 (errorCallback 함수를 지정한 경우) errorCallback 함수를 호출합니다. 발생 가능한 에러 코드는 다음과 같습니다.
•NOT_SUPPORTED_ERR: 이 피쳐가 지원되지 않는 경우
•SECURITY_ERR: 이 연산이 허용되지 않는 경우
•UNKNOWN_ERR: 그 밖에 다른 모든 경우
var addressbook; // Define the error callback for all the asynchronous calls function errorCallback(response) { alert( "The following error occurred: " + response.code); } function contactUpdatedCB() { // The contact has been successfully updated alert('Contact Successfully updated'); } function contactFoundCB(contacts) { // The contact has been successfully found // Let's try to change the summary contacts[0].firstName = "Jeffrey Ross"; addressbook.updateContact(contactUpdatedCB, errorCallback, contacts[0]); } function contactAddedCB(contact) { // The contact has been successfully added // Let's try to check if we can retrieve the added // contact from the address book. If the address book // was empty only the item added through addContact should // be returned addressbook.findContacts(contactFoundCB, errorCallback, {firstName:'%Jeffrey%'}); } // Define the success callback for retrieveing all the // Address Books function AddressBooksCB(addressbooks) { if(addressbooks.length > 0) { addressbook = addressbooks[0]; alert("The addressbook type is " + addressbook.type + " and name " + addressbook.name); var contact = addressbook.createContact( {firstName:'Jeffrey', lastName:'Hyman', nicknames:['joey ramone'], emails:[{email:'user@domain.com'}], phoneNumbers:[{number:'666666666'}]}); addressbook.addContact(contactAddedCB, errorCallback, contact); } } // Get a list of available Address Books. deviceapis.pim.contact.getAddressBooks(AddressBooksCB, errorCallback);- Parameters:
- {AddressBookArraySuccessCallback} successCallback
주소록을 얻는 데 성공한 경우 콜백으로 호출됩니다
- {ErrorCallback} errorCallback
주소록을 얻는 데 실패한 경우 콜백으로 호출됩니다.
- Throws:
매개변수의 형식이 올바르지 않은 경우 TYPE_MISMATCH_ERR 오류 코드와 함께 발생됩니다.
- Returns:
- {PendingOperation}
비동기 방식으로 호출된 함수를 취소할 수 있는 PendingOperation 객체입니다.
