Enviar pesquisa
Carregar
AddressBook to Contacts
•
3 gostaram
•
2,948 visualizações
Takaaki Tanaka
Seguir
第三回iOS 9 bootcampでの発表資料です
Leia menos
Leia mais
Engenharia
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 70
Baixar agora
Baixar para ler offline
Recomendados
Unattended OutSystems Installation
Unattended OutSystems Installation
OutSystems
Eight Principles of Information Architecture
Eight Principles of Information Architecture
Dan Brown
Linux Presentation
Linux Presentation
ThakurJiKaLadka
OKR, Ziele und Zielsysteme im Agilen
OKR, Ziele und Zielsysteme im Agilen
Björn Schotte
Remote administration
Remote administration
Suja Ritha
Good Design Principles for App Developer (UAB) 2017
Good Design Principles for App Developer (UAB) 2017
Marçal P.
UI vs UX workshop
UI vs UX workshop
Inova LLC
UX DESIGN & HACKATHON - UM GUIA DE SOBREVIVÊNCIA
UX DESIGN & HACKATHON - UM GUIA DE SOBREVIVÊNCIA
Guilherme Gonzalez
Recomendados
Unattended OutSystems Installation
Unattended OutSystems Installation
OutSystems
Eight Principles of Information Architecture
Eight Principles of Information Architecture
Dan Brown
Linux Presentation
Linux Presentation
ThakurJiKaLadka
OKR, Ziele und Zielsysteme im Agilen
OKR, Ziele und Zielsysteme im Agilen
Björn Schotte
Remote administration
Remote administration
Suja Ritha
Good Design Principles for App Developer (UAB) 2017
Good Design Principles for App Developer (UAB) 2017
Marçal P.
UI vs UX workshop
UI vs UX workshop
Inova LLC
UX DESIGN & HACKATHON - UM GUIA DE SOBREVIVÊNCIA
UX DESIGN & HACKATHON - UM GUIA DE SOBREVIVÊNCIA
Guilherme Gonzalez
Ui ux designing principles
Ui ux designing principles
Dzung Nguyen
Mapping Experiences
Mapping Experiences
Jim Kalbach
i/o extended: Intro to <UX> Design
i/o extended: Intro to <UX> Design
GDGKuwaitGoogleDevel
Designsysteme (deutsch) #UXcampHH
Designsysteme (deutsch) #UXcampHH
Benno Lœwenberg
Introduction to User Experience Design
Introduction to User Experience Design
Ravi Bhadauria
UX/UI design
UX/UI design
JuliaMezhennaya
"Don't Reply All" Book Summary
"Don't Reply All" Book Summary
Hassan Osman, PMP
Design Prinzipien für Green UX
Design Prinzipien für Green UX
trashlessguy
Usability: Part of User Experience (UX)
Usability: Part of User Experience (UX)
Edneil Jocusol
10 spaces-ux capabilities-presentation
10 spaces-ux capabilities-presentation
Matt DeYoung
Look at UI/UX Design Process
Look at UI/UX Design Process
Elumalai Jayaraman
Usability basics
Usability basics
Zdeněk Lanc
Linux
Linux
dwarfyray
How to Find a Good UI/UX Designer (or be one!)
How to Find a Good UI/UX Designer (or be one!)
Emerentiana Meicy
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Agile India
UX Design process, #UX, #Design Process, #Agile UX
UX Design process, #UX, #Design Process, #Agile UX
Murali Krishna
Human computer interaction
Human computer interaction
Mayuresh Singh
DNN as a Headless CMS
DNN as a Headless CMS
Mandeep Singh
Lean UX
Lean UX
UX REPUBLIC
UI and UX Design for Startups - Matin Maleki
UI and UX Design for Startups - Matin Maleki
Matin Maleki
User guide
User guide
ricemjr124
HTML5 addressbook
HTML5 addressbook
Anbarasan Gangadaran
Mais conteúdo relacionado
Mais procurados
Ui ux designing principles
Ui ux designing principles
Dzung Nguyen
Mapping Experiences
Mapping Experiences
Jim Kalbach
i/o extended: Intro to <UX> Design
i/o extended: Intro to <UX> Design
GDGKuwaitGoogleDevel
Designsysteme (deutsch) #UXcampHH
Designsysteme (deutsch) #UXcampHH
Benno Lœwenberg
Introduction to User Experience Design
Introduction to User Experience Design
Ravi Bhadauria
UX/UI design
UX/UI design
JuliaMezhennaya
"Don't Reply All" Book Summary
"Don't Reply All" Book Summary
Hassan Osman, PMP
Design Prinzipien für Green UX
Design Prinzipien für Green UX
trashlessguy
Usability: Part of User Experience (UX)
Usability: Part of User Experience (UX)
Edneil Jocusol
10 spaces-ux capabilities-presentation
10 spaces-ux capabilities-presentation
Matt DeYoung
Look at UI/UX Design Process
Look at UI/UX Design Process
Elumalai Jayaraman
Usability basics
Usability basics
Zdeněk Lanc
Linux
Linux
dwarfyray
How to Find a Good UI/UX Designer (or be one!)
How to Find a Good UI/UX Designer (or be one!)
Emerentiana Meicy
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Agile India
UX Design process, #UX, #Design Process, #Agile UX
UX Design process, #UX, #Design Process, #Agile UX
Murali Krishna
Human computer interaction
Human computer interaction
Mayuresh Singh
DNN as a Headless CMS
DNN as a Headless CMS
Mandeep Singh
Lean UX
Lean UX
UX REPUBLIC
UI and UX Design for Startups - Matin Maleki
UI and UX Design for Startups - Matin Maleki
Matin Maleki
Mais procurados
(20)
Ui ux designing principles
Ui ux designing principles
Mapping Experiences
Mapping Experiences
i/o extended: Intro to <UX> Design
i/o extended: Intro to <UX> Design
Designsysteme (deutsch) #UXcampHH
Designsysteme (deutsch) #UXcampHH
Introduction to User Experience Design
Introduction to User Experience Design
UX/UI design
UX/UI design
"Don't Reply All" Book Summary
"Don't Reply All" Book Summary
Design Prinzipien für Green UX
Design Prinzipien für Green UX
Usability: Part of User Experience (UX)
Usability: Part of User Experience (UX)
10 spaces-ux capabilities-presentation
10 spaces-ux capabilities-presentation
Look at UI/UX Design Process
Look at UI/UX Design Process
Usability basics
Usability basics
Linux
Linux
How to Find a Good UI/UX Designer (or be one!)
How to Find a Good UI/UX Designer (or be one!)
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
Strategic Domain-Driven Design by Nick Tune at #AgileIndia2019
UX Design process, #UX, #Design Process, #Agile UX
UX Design process, #UX, #Design Process, #Agile UX
Human computer interaction
Human computer interaction
DNN as a Headless CMS
DNN as a Headless CMS
Lean UX
Lean UX
UI and UX Design for Startups - Matin Maleki
UI and UX Design for Startups - Matin Maleki
Destaque
User guide
User guide
ricemjr124
HTML5 addressbook
HTML5 addressbook
Anbarasan Gangadaran
AEGEE - Address Book Project - Agora Aachen
AEGEE - Address Book Project - Agora Aachen
aegee.statutory
Address Book
Address Book
NIKITHA PERUMALLA
Srand011 personal addressbook
Srand011 personal addressbook
Androidproject
Harrell - Revisioning Strengths and Virtues in the Context of Gender and Culture
Harrell - Revisioning Strengths and Virtues in the Context of Gender and Culture
Shelly Harrell
Address Book
Address Book
bpr4s
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan
Address book
Address book
Siva Rushi
Software requirements specification
Software requirements specification
Krishnasai Gudavalli
SlideShare 101
SlideShare 101
Amit Ranjan
Destaque
(11)
User guide
User guide
HTML5 addressbook
HTML5 addressbook
AEGEE - Address Book Project - Agora Aachen
AEGEE - Address Book Project - Agora Aachen
Address Book
Address Book
Srand011 personal addressbook
Srand011 personal addressbook
Harrell - Revisioning Strengths and Virtues in the Context of Gender and Culture
Harrell - Revisioning Strengths and Virtues in the Context of Gender and Culture
Address Book
Address Book
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
Address book
Address book
Software requirements specification
Software requirements specification
SlideShare 101
SlideShare 101
Mais de Takaaki Tanaka
Server Side? Swift
Server Side? Swift
Takaaki Tanaka
Swiftをキめると 気持ちいい!
Swiftをキめると 気持ちいい!
Takaaki Tanaka
Enumはデキる子 ~ case .Success(let value): ~
Enumはデキる子 ~ case .Success(let value): ~
Takaaki Tanaka
AndroidーiOS開発比較〜iOSエンジニアから見たAndroidのアレコレ〜
AndroidーiOS開発比較〜iOSエンジニアから見たAndroidのアレコレ〜
Takaaki Tanaka
全部見せます!最前線エンジニアが語るBleアプリケーションのハマりどころ(i os)
全部見せます!最前線エンジニアが語るBleアプリケーションのハマりどころ(i os)
Takaaki Tanaka
Swift api design guidelines (dec 3, 2015)
Swift api design guidelines (dec 3, 2015)
Takaaki Tanaka
モバイル開発者から見た サーバーレスアーキテクチャ
モバイル開発者から見た サーバーレスアーキテクチャ
Takaaki Tanaka
Mais de Takaaki Tanaka
(7)
Server Side? Swift
Server Side? Swift
Swiftをキめると 気持ちいい!
Swiftをキめると 気持ちいい!
Enumはデキる子 ~ case .Success(let value): ~
Enumはデキる子 ~ case .Success(let value): ~
AndroidーiOS開発比較〜iOSエンジニアから見たAndroidのアレコレ〜
AndroidーiOS開発比較〜iOSエンジニアから見たAndroidのアレコレ〜
全部見せます!最前線エンジニアが語るBleアプリケーションのハマりどころ(i os)
全部見せます!最前線エンジニアが語るBleアプリケーションのハマりどころ(i os)
Swift api design guidelines (dec 3, 2015)
Swift api design guidelines (dec 3, 2015)
モバイル開発者から見た サーバーレスアーキテクチャ
モバイル開発者から見た サーバーレスアーキテクチャ
AddressBook to Contacts
1.
AddressBook to Contacts クラスメソッド株式会社 モバイルアプリサービス部 田中 孝明
2.
自己紹介 名前 田中 孝明 出身
岡山県 iOS 開発歴 2011 ∼ (ブランクあり) 入社歴 14
3.
9月27日に福岡から来ました
4.
5.
閑話休題
6.
AddressBook Contacts
7.
Reference • What's New
in iOS 9.0 • Introducing the Contacts Framework for iOS and OS X • Address Book Framework Reference for iOS • Contacts Framework Reference • http://qiita.com/koogawa/items/ 44ce2e1fb127b884d835
8.
Agenda • 1. 連絡先について •
2. AddressBookとContactsについて • 3. Privacyについて • 4. Fetchの違いについて • 5. 連絡先の編集の違いについて
9.
1. 連絡先について
10.
連絡先について • 連絡先に登録されているユーザーのデータベースを管理
11.
連絡先について • 名前 • 電話番号 •
email • 所属 • 住所 • 誕生日 • …etc
12.
連絡先にアクセスするアプリ • ユーザーの検索 • 友人の招待 •
ユーザーの登録
13.
活躍の場の例 • サポートデスクの連絡先を追加する • 社員の連絡先を追加する •
指定された連絡先のみを削除する
14.
2. AddressBookと Contactsについて
15.
AddressBookとContactsについて • どちらにもUIとsuffixが付いているフレームワークがあ り、連絡先の追加、参照、削除をする画面を提供してい る
16.
• CNContactPickerViewControllerを生成し、 presentViewControllerをするだけで簡単に 使用できる ContactsUI let contactPickerViewController
= CNContactPickerViewController() contactPickerViewController.delegate = self self.presentViewController( contactPickerViewController, animated: true, completion: nil)
17.
• 一覧表示
18.
• グループ
19.
•詳細表示
20.
•複数選択
21.
地味…
22.
What's New in
iOS 9.0 • AddressBookフレームワークがiOS 9から deprecatedに • AddressBookUIの方もdeprecatedに • 現時点ではiOS 9でも使えないこともない…
23.
What's New in
iOS 9.0 • iOS 9でContactsフレームワークが追加された • iOS 9からしか使用できない • iOS 8以下もサポートする場合は AddressBookと共存させなければならない
24.
AddressBookでは⚪⚪だったものが Contactsではxxになる、 といった観点で説明いたします。
25.
AddressBook • iOS専用の連絡先アクセスAPI • Mac用は別に存在する •
Objective-C / Swift両方使用可能 • You must ensure that an instance of ABAddressBookRef is used by only one thread.
26.
AddressBook • CoreFoundation…
27.
28.
メモリリーク怖い…
29.
Contacts • iOS /
Macの連絡先アクセスAPI • watchOS 2に対応 • Objective-C / Swift両方使用可能 • thread-safe(fetch & save)
30.
Contacts
31.
3. Privacyについて
32.
Privacy
33.
連絡先アクセス許可状態を取得 let status = CNContactStore.authorizationStatusForEntityType (.Contacts) ABAuthorizationStatus
status = ABAddressBookGetAuthorizationStatus(); • AddressBook • Contacts
34.
AddressBook Contacts ステータス CNAuthorizationStat usNotDetermined NotDetermined 許可/不許可問い合わ せ前 CNAuthorizationStat usRestricted Restricted 管理者より機能制限 (ユーザー、アプリに よる変更は不可) CNAuthorizationStat usDenied Denied ユーザーによって不許 可 CNAuthorizationStat usAuthorized Authorized ユーザーによって許可 されている
35.
AddressBook • 連絡先アクセスの許可をユーザーに問い合わせる CFErrorRef cfError
= NULL; ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &cfError); ABAddressBookRequestAccessWithCompletion( addressBook, ^(bool inGranted, CFErrorRef inCfError) { NSLog(@"inGranted: %d", inGranted); });
36.
Contacts • 連絡先アクセスの許可をユーザーに問い合わせる let store
= CNContactStore() store.requestAccessForEntityType( .Contacts, completionHandler:{ (granted: Bool, error: NSError?) -> Void in print("granted: (granted)") })
37.
確認用のアラート
38.
• 許可は設定>プライバシー>連絡先で変更可能
39.
4. Fetchの違いに ついて
40.
AddressBook • RecordIDを指定して取得 • 名前から検索 (ABAddressBookCopyPeopleWithName) Contacts •
CNContact.identifierを指定して取得 • 名前から検索(unifiedContactsMatchingPredicate)
41.
連絡先データベースの作成 Contacts AddressBook CFErrorRef cfError =
NULL; ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &cfError); let store = CNContactStore()
42.
AddressBook • RecordIDを指定して取得 • RecordIDはAddressBookデータベースに書き込 まれた一意の値 •
型はint 32 int32_t recordId = (int32_t)recordIdNumber.intValue; ABRecordRef person = ABAddressBookGetPersonWithRecordID( addressBook, recordId);
43.
Contacts • CNContact.identifierを使用して取得 • String型 •
AddressBookのRecordIDと互換性がない let identifier = "035218FA-1E6E-4D1C-9708-76FBC0E55F28" let contact = try store.unifiedContactWithIdentifier( identifier, keysToFetch:[ CNContactGivenNameKey, CNContactFamilyNameKey])
44.
AddressBook • 名前から検索 • 「姓」「姓読み」「名」「名読み」のどれか該 当するものをFetchする •
戻り値はCFArrayRef… NSString *name = @"Appleseed"; CFArrayRef contacts = ABAddressBookCopyPeopleWithName( addressBook, (__bridge CFStringRef)name);
45.
Contacts • 名前から検索(unifiedContactsMatchingPredicate) • keysToFetchにはFetchしてきたいプロパティのキーを指定 let
predicate = CNContact.predicateForContactsMatchingName( “Appleseed") let contacts = try store.unifiedContactsMatchingPredicate( predicate, keysToFetch:[CNContactGivenNameKey, CNContactFamilyNameKey])
46.
Contacts • keysToFetchに指定していないプロパティ へはアクセスできない let predicate
= CNContact.predicateForContactsMatchingName( "Appleseed") let contacts = try store.unifiedContactsMatchingPredicate( predicate, keysToFetch:[CNContactGivenNameKey, CNContactFamilyNameKey]) let contact = contacts.first print("(contact!.identifier) (contact!.givenName) (contact!.familyName) (contact!.phoneNumbers)")
47.
Contacts • アクセスする前にキーが指定されているかを チェックする if contact!.isKeyAvailable( CNContactPhoneNumbersKey)
{
48.
Contacts • フルネームを取得する際KeysToFetchに全て指定しない let contacts
= try store.unifiedContactsMatchingPredicate( predicate, keysToFetch:[ CNContactGivenNameKey, CNContactFamilyNameKey, CNContactNamePrefixKey, CNContactMiddleNameKey, CNContactNameSuffixKey, CNContactPhoneNumbersKey])
49.
Contacts • CNContactFommatterを使用する let contacts
= try store.unifiedContactsMatchingPredicate( predicate, keysToFetch[ CNContactFormatter. descriptorForRequiredKeysForStyle(.FullName), CNContactPhoneNumbersKey])
50.
比較 AddressBook Contacts データベース ABAddressBookRef
CNContactStore 連絡先 ABRecordRef CNContact グループ ABRecordRef CNGroup
51.
各プロパティ対応 AddressBook Contacts FirstName(Takaaki) kABPersonFirstName Property givenName LastName(Tanaka) kABPersonLastName Property familyName MiddleName(F) kABPersonMiddle NameProperty middleName Prefix(Mr.) kABPersonPrefix Property namePrefix Suffix(Jr.) kABPersonSuffix Property nameSuffix Nickname kABPersonNickname Property nickname
52.
• Conctacs.frameworkからはFetchしてくる必要がある プロパティはキーを指定しなければならない • AddressBookでIDから検索するロジックを実装してい る場合はマイグレーション処理等で Contact.identifierに置き換える必要がある
53.
5. 連絡先の編集の違い
54.
AddressBook • 新規追加の場合(全体) CFErrorRef cfError
= NULL; ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &cfError); if (!addressBook) { NSError *error = (__bridge_transfer NSError *)cfError; NSLog(@"%s: %@", __PRETTY_FUNCTION__, error); } ABRecordRef person = ABPersonCreate(); ABRecordSetValue(person, kABPersonFirstNameProperty, (__bridge CFTypeRef)@"John", &cfError); ABRecordSetValue(person, kABPersonLastNameProperty, (__bridge CFTypeRef)@"Appleseed", &cfError); ABAddressBookAddRecord(addressBook, person, &cfError); ABAddressBookSave(addressBook, &cfError);
55.
AddressBook • ABAddressBookRefを作成する CFErrorRef cfError
= NULL; ABAddressBookRef addressBook = ABAddressBookCreateWithOptions( NULL, &cfError); if (!addressBook) { NSError *error = (__bridge_transfer NSError *)cfError; NSLog(@"%s: %@", __PRETTY_FUNCTION__, error); }
56.
AddressBook • ABRecordRefを取得する ABRecordRef person
= ABPersonCreate(); ABRecordSetValue(person, kABPersonFirstNameProperty, (__bridge CFTypeRef)@"John", &cfError); ABRecordSetValue(person, kABPersonLastNameProperty, (__bridge CFTypeRef)@"Appleseed", &cfError); • 必要なプロパティをセットする
57.
AddressBook • MultiValueを追加する場合 CFErrorRef cfError
= NULL; ABMultiValueIdentifier identifier; ABMultiValueRef multiTel = ABMultiValueCreateMutable(kABMultiStringPropertyType); CFStringRef label1 = kABPersonPhoneMainLabel; NSString *value1 = @"012-345-6789"; ABMultiValueAddValueAndLabel( multiTel, (__bridge CFTypeRef)(value1), label1, &identifier); CFStringRef label2 = kABPersonPhoneIPhoneLabel; NSString *value2 = @"111-222-3333"; ABMultiValueAddValueAndLabel( multiTel, (__bridge CFTypeRef)(value2), label2, &identifier); ABRecordSetValue( person, kABPersonPhoneProperty, multiTel, &cfError); CFRelease(multiTel);
58.
AddressBook • AddressBookに対する操作を指定する • AddressBookに対するセーブを実施する ABAddressBookAddRecord( addressBook,
person, &cfError); ABAddressBookSave(addressBook, &cfError);
59.
Contacts • 新規追加の場合(全体) let store
= CNContactStore() let contact = CNMutableContact() contact.givenName = "John" contact.familyName = "Appleseed" let saveRequest = CNSaveRequest() saveRequest.addContact(contact, toContainerWithIdentifier:nil) do { try store.executeSaveRequest(saveRequest) } catch { abort() }
60.
Contacts • CNContactStoreを取得 • CNMutableContactを取得する let
store = CNContactStore() let contact = CNMutableContact()
61.
Contacts • 必要なプロパティをセットする contact.givenName =
"John" contact.familyName = "Appleseed"
62.
Contacts • MultiValueを追加する場合 let mainNumber
= CNLabeledValue( label:CNLabelPhoneNumberMain, value:"012-345-6789") let iPhoneNumber = CNLabeledValue( label:CNLabelPhoneNumberiPhone, value:"111-222-3333") contact.phoneNumbers = [mainNumber, iPhoneNumber]
63.
Contacts • CNSaveRequestへデータベースへの操作を指定する • CNContactStoreに対してセーブを実施する let
saveRequest = CNSaveRequest() saveRequest.addContact( contact, toContainerWithIdentifier:nil) try store.executeSaveRequest(saveRequest)
64.
Contacts Changed Notifications •
CNContactStoreDidChangeNotification • CNContactStoreに変更があった際に NSNotificationCenterから通知を受ける
65.
まとめ • 新規作成、編集、削除ロジック部分はあまり変更はない • Fetchのしかたに変更はあるが、大幅な変更はない •
RecordIDとIdentifierに互換性がない • Contacts.frameworkはiOS 9以降でしか使用できない • AddressBookを使用している場合はContactsでも同じロジッ クで実装し、iOS 8のサポート切れのタイミングで切り離せる ようにするほうが良い
66.
if #available(iOS 9.0,
*) {
67.
68.
69.
70.
ありがとうございました
Baixar agora