2016-11-16 2 views
0

이것은 기기 연락처를 가져 오는 코드이며이 연락처를 내 Gmail 계정으로 이동하여 복사하려고합니다.연락처를 Gmail 계정으로 이동하고 복사하는 방법 iOS

CNContactStore *contactStore = [[CNContactStore alloc] init]; 
NSArray *keys = [[NSArray alloc]initWithObjects:CNContactJobTitleKey,CNContactNoteKey,CNContactBirthdayKey,  CNContactThumbnailImageDataKey, CNContactPhoneNumbersKey,CNContactEmailAddressesKey,CNContactTypeKey, CNContactViewController.descriptorForRequiredKeys,CNContainerIdentifierKey, nil]; 
CNContactFetchRequest *request = [[CNContactFetchRequest alloc] initWithKeysToFetch:keys]; 
request.predicate = nil; 
[contactStore enumerateContactsWithFetchRequest:request error:nil usingBlock:^(CNContact* __nonnull contact, BOOL* __nonnull stop){ 

}];  

답변

1

가장 기본적인 장소는 Google Contacts API입니다.

하지만 시간이 많이 걸리고 쉽지 않을 것입니다. 옵션이 아닌 경우 GitHub에서 적절한 것을 찾아보십시오.

Duraing 빠른 검색 난 this 라이브러리를 발견했습니다. 그것이 당신이 필요로하는 것을 정확하게하지 않더라도, 당신은 어떻게 당신이 구글의 API를 통합하기로되어 있는지 통찰력을 얻을 수 있습니다.

타사 라이브러리를 사용하지 않기로 결정한 경우 수행해야하는 작업입니다. (자세한 내용은 here을 참조하십시오.) :

1) 당신은 authorize이 필요합니다.

POST /m8/feeds/contacts/default/full 
Content-Type: application/atom+xml 
GData-Version: 3.0 
... 

요청 본문 :

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" 
    xmlns:gd="http://schemas.google.com/g/2005"> 
    <atom:category scheme="http://schemas.google.com/g/2005#kind" 
    term="http://schemas.google.com/contact/2008#contact"/> 
    <gd:name> 
    <gd:givenName>Elizabeth</gd:givenName> 
    <gd:familyName>Bennet</gd:familyName> 
    <gd:fullName>Elizabeth Bennet</gd:fullName> 
    </gd:name> 
    <atom:content type="text">Notes</atom:content> 
    <gd:email rel="http://schemas.google.com/g/2005#work" 
    primary="true" 
    address="[email protected]" displayName="E. Bennet"/> 
    <gd:email rel="http://schemas.google.com/g/2005#home" 
    address="[email protected]"/> 
    <gd:phoneNumber rel="http://schemas.google.com/g/2005#work" 
    primary="true"> 
    (206)555-1212 
    </gd:phoneNumber> 
    <gd:phoneNumber rel="http://schemas.google.com/g/2005#home"> 
    (206)555-1213 
    </gd:phoneNumber> 
    <gd:im address="[email protected]" 
    protocol="http://schemas.google.com/g/2005#GOOGLE_TALK" 
    primary="true" 
    rel="http://schemas.google.com/g/2005#home"/> 
    <gd:structuredPostalAddress 
     rel="http://schemas.google.com/g/2005#work" 
     primary="true"> 
    <gd:city>Mountain View</gd:city> 
    <gd:street>1600 Amphitheatre Pkwy</gd:street> 
    <gd:region>CA</gd:region> 
    <gd:postcode>94043</gd:postcode> 
    <gd:country>United States</gd:country> 
    <gd:formattedAddress> 
     1600 Amphitheatre Pkwy Mountain View 
    </gd:formattedAddress> 
    </gd:structuredPostalAddress> 
</atom:entry> 
새 연락처를 생성하는 요청을 보낼 수 후

2)