2014-12-11 3 views
0

티타늄 메신저에서 전화 번호부에 액세스하고 연락처 정보 (단일 및 다중 값 필드)가있는 배열이 있습니다. 나는 multi-value 전자 우편 분야에 말썽이있다.다중 티타늄 요소를 티타늄 (JS) 배열로 푸시

email: {"work":["[email protected]","www.icloud.com"]} 
phone: {"work":["(555) 766-4823"],"other":["(707) 555-1854"]} 

코드 내가 지금까지 가지고 :

function buddy_check(){ 
    var all_emails= []; // array of emails from senders contacts 
    var multiValue = ['email']; 
    var people = Ti.Contacts.getAllPeople(); // gets all contacts (recordId, name,…) 
    for (var i=0, ilen=people.length; i<ilen; i++){ 
     Ti.API.info('---------------------'); 
     var person = people[i]; 
    //for (var j=0, jlen=singleValue.length; j<jlen; j++){ 
    // Ti.API.info(singleValue[j] + ': ' + person[singleValue[j]]); 
    // } 
    for (var j=0, jlen=multiValue.length; j<jlen; j++){ 
     Ti.API.info(multiValue[j] + ': ' + JSON.stringify(person[multiValue[j]])); 
     all_emails.push(); 
    } 
} 

다중 값 필드도 캐릭터 라인 객체는 다음과 같이 (작업 직장, 가정, 기타뿐만 아니라 여러 이메일, 집 등)를 찾습니다 전화 번호부의 모든 이메일을 쉼표로 구분하여 하나의 배열로 필요로합니다. 밑줄 함수도 잘 작동합니다.

내가 all_emails 배열로 무엇을 밀어 넣어야합니까? 이메일을 추출하여 배열 (예 : "@"로 검색)에 넣는 간단한 방법이 있습니까?

통찰력을 공유하기위한 thx!

P.S : 사용자가 이메일을 우리의 데이터베이스 확인되고 있음을 통보 물론이다.

답변

0

여기에서 : - : http://www.oodlestechnologies.com/blogs/How-to-extract-contact-list-having-phone-numbers-and-emails-from-iPhone-contacts-using-Titanium#sthash.q7TJF8Lg.dpuf

http://www.oodlestechnologies.com/blogs/How-to-extract-contact-list-having-phone-numbers-and-emails-from-iPhone-contacts-using-Titanium

var data = []; 
var people = Ti.Contacts.getAllPeople(); 

for (var i = 0, 
    ilen = people.length; i < ilen; i++) { 
    var person = people[i]; 
    var title = people[i].fullName; 
    if (!title || title.length === 0) { 
     title = "No Name"; 
    } 
    Ti.API.info("person name : " + title); 

    var personEmails = []; 
    //this check is used for conforming that array will contain at least one email that is actual. 
    var actualConfirmed = false; 
    //fetching emails 
    //Ti.API.info("person email::::1 " + JSON.stringify(person.email)); 
    for (var temp in person.email) { 
     var temp_emails = person.email[temp]; 
     if (temp_emails && (temp_emails.length > 0)) { 
      //Ti.API.info("person email::::2 " + JSON.stringify(temp_emails)); 
      for (var k = 0; k < temp_emails.length; k++) { 
       var temp_email = temp_emails[k]; 
       var isActualEmail = emailValidation(temp_email); 
       Ti.API.info("temp_email " + temp_email + " :::: isActualEmail " + isActualEmail); 
       if (isActualEmail) { 
        actualConfirmed = true; 
        personEmails.push(temp_email); 
       } 
      } 
     } 
    } 

에서 자세한 내용을 참조하십시오