2016-11-16 11 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で適切なものを見つけることを検討することがあります。

クイック検索を中止しました。thisライブラリを見つけました。必要なものを正確に実行しなくても、Googleの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)

関連する問題