2012-07-29 4 views
3

PhoneGap이 버전 2.0이므로 연락처 선택 도구를 사용할 수있는 방법이 있습니까?PhoneGap 연락처 선택 도구

docs는 모든 사용자의 연락처를 요청한 다음 내 자신의 인앱 연락처 선택기를 작성하여 자바 스크립트로 직접 작성해야하는 것처럼 보입니다.

http://docs.phonegap.com/en/2.0.0/cordova_contacts_contacts.md.html#Contacts

내가 일회성 플러그인 안드로이드를 발견했습니다,하지만 난 여전히 내 자신을 작성해야 할 것 다음의 원인, 어떤 플러그인 아이폰에 대한 존재하지 않는 경우는 그 도움이되지이다. "사용자가 연락처를 선택하고 그 연락처 정보로 여기로 다시 보내도록하십시오"라는 장치 독립적 방법을 찾고 있습니다.

답변

1

이 솔루션을 Android에서도 사용할 수 있는지 여부는 알 수 없지만 iPhone의 경우 .chooseContact() 메소드를 사용할 수 있습니다.

예 :

<a href="#" onclick="contactChooser()">Choose a contact</a> 


    function contactChooser(){ 

    //The chooseContact method will open a new window with all you contacts 
    navigator.contacts.chooseContact(

     //After picking a name you will receive the id of the chosen contact 
     function(id){ 

      //In an options variable you can set some filter parameters 
      //In this example we will use the Id to receive the data of the chosen contact 
      var options = { 
       filter: ""+id 
      } 

      //In the fields variable we're going to set the fields we want to receive 
      //'*' = every data. More field values are explained 
      // here: http://bit.ly/T8YyuE 
      var fields = ['*']; 

      navigator.contacts.find(fields, onPickContactSuccess, onPickContactError, options); 
     }, null); 
    } 

    function onPickContactSuccess(contacts){ 
     //contacts contains all data you've requested 

     var _name = contacts[0].name 

     alert('Last: '+_name.familyName+' First: '+_name.givenName); 
    } 
+0

그냥 참고 :이은 iOS 용 문서화되지 않은 기능이 될 것으로 보인다. https://groups.google.com/forum/?fromgroups#!topic/phonegap/JI42d5prb-I를 참조하십시오. – Anthony