iOS How to Access Contacts and Address Book (Contacts Framework)

  Рет қаралды 11,347

CodeWithChris

CodeWithChris

Күн бұрын

Using Apple’s Contacts framework, we’ll be able to request permission from the user and access their contacts information in their address book. The code to do this is extremely simple and I’ll show you how in this video.
Timestamps:
00:00 Intro
00:26 Importing Contacts framework
02:30 Contacts store
08:21 Asking user for permission to access contacts
11:21 Fetching all contacts
11:59 Extracting contact information
16:37 Searching for contacts
20:25 User denied the request to access contacts
Reference Links:
Apple Documentation: Contacts
Apple Documentation: Contact Keys
Apple Documentation: CNContactFetchRequest
🚨 SPECIAL CWC+ OFFER FOR KZfaq:
cwc.to/youtubeoffer
MY FREE ONLINE COURSE:
⚡ How to make an app in 14 days - cwc.to/14days
CWC+ PROGRAM:
👩‍💻 All our courses in a learning path - cwc.to/plus
WEEKLY UPDATES VIA EMAIL:
✉️ Every Saturday, receive an email digest of new content - cwc.to/newsletter
CONNECT:
🌍 Website - codewithchris.com
😺 GitHub - github.com/codewithchris
📸 Instagram - / codewithchris
🐦 Twitter - / codewithchris
ABOUT CODEWITHCHRIS:
Hi I’m Chris! I’m dedicated to teaching fundamentals about how to make an app. This is important if you’re trying to land an iOS job, be a freelancer, increase or start a business with an app idea. On this channel and my website, you'll find a ton of free resources and tutorials to aid you on your journey to learn iOS development. Many people have learned to code and build apps on their own! cwc.to/reviews
DID THESE LESSONS HELP YOU?
Please let me know! - feedback.codewithchris.com
ROADMAP:
roadmap.codewithchris.com

Пікірлер: 29
@nigelpardoe7665
@nigelpardoe7665 3 ай бұрын
Really well explained, thanks Chris
@rungxanh2901
@rungxanh2901 9 ай бұрын
15:10 is real gold. Thanks Chris!
@ezequiellarsen4529
@ezequiellarsen4529 6 ай бұрын
Super helpful and clear. I come back to your video from time to time. Thanks Chris!
@CodeWithChris
@CodeWithChris 6 ай бұрын
Thanks for watching! I'll be sure to let Chris know :) - Iñaki
@KimbrellBrad
@KimbrellBrad 2 жыл бұрын
Great concepts here Chris! I recently had to export my Contacts from my work iMac to my new home office iMac. Some of the imported data landed in the wrong slots. This tutorial will help me to create a process to verify and update items that are incorrectly formatted. Thanks for this! Your tutorials are always very easy to understand and so many times you seem to find items that I have been curious about.
@CodeWithChris
@CodeWithChris 2 жыл бұрын
Thanks for the kind words! Kind people like you keep us going. Much love! -Arthur
@ChapterIt
@ChapterIt 9 ай бұрын
Chapters (powered by ChapterIt): 0:00 - Introduction and Overview 1:01 - Importing the Contacts Framework 2:26 - Fetching All Contacts 3:22 - Handling Permission Errors 4:22 - Creating the Contact Fetch Request 5:27 - Specifying Keys to Fetch 6:51 - Recap and Conclusion 7:16 - Writing Code for Each Contact 8:21 - Asking for Permission to Access Contacts 9:05 - Adding NSContactsUsageDescription Key 10:13 - Running the App Without Permission 10:39 - Accessing Contacts in the Background 11:24 - Running the App with Permission 11:46 - Printing Contact Information 12:56 - Looping Through Phone Numbers 14:07 - Accessing Phone Number Label and Value 15:20 - Accessing Contact Number Value 15:37 - Printing Phone Number Labels 15:53 - Default Phone Number 16:07 - Displaying Formatted Phone Numbers 16:12 - Using a Switch Statement 16:36 - Searching for Specific Contacts 16:54 - Async Method for Fetching Specific Contacts 17:16 - Unified Contacts Matching 17:29 - Creating Predicate and Keys to Fetch 18:12 - Using Contact Predicate 18:27 - Different Matching Options 19:09 - Unified Contacts Matching in a Do-Catch Block 20:09 - Printing Fetched Contacts 20:23 - Handling User Denial of Access 21:30 - Catching Access Denied Error 22:05 - Granting Access in Settings
@HenningMoeller
@HenningMoeller 2 жыл бұрын
Hi Chris, nice video. Pls. give us more of them. Can you make a video about access to CNContactNoteKey? Best regards from Germany.
@CodeWithChris
@CodeWithChris 2 жыл бұрын
Guten tag! Can you kindly post your request here: app.productstash.io/codewithchris#/ideas Danke! -Arthur
@AnatoliyTsvetkov
@AnatoliyTsvetkov 2 жыл бұрын
Sound of your custom keyboard is so appealing and nice to hear! And you =))
@CodeWithChris
@CodeWithChris 2 жыл бұрын
Cheers, thanks for the love! -Arthur
@HR_Breeding
@HR_Breeding 2 жыл бұрын
Hi Chris good video 👍👍👍
@CodeWithChris
@CodeWithChris 2 жыл бұрын
You are so welcome! -Arthur
@maksimbobukh4040
@maksimbobukh4040 Жыл бұрын
Hey! Your keyboard sounds amazing🤯😍 Could you please provide a name of it?
@RichardBaileyrichoncode
@RichardBaileyrichoncode 7 ай бұрын
Nice intro. Would be good to cover contacts ui too. Hard coding display strings is limited. Also, how are custom phone types handled?
@swathi5812
@swathi5812 3 ай бұрын
hey chris, how can i access favorite contacts in contacts frame work?
@aldobergamini462
@aldobergamini462 4 ай бұрын
Very nice video! I do have a question, that is about something of a follow up to this intro, but in the same area of iOS Is it possible to add custom fields to contacts in system contacts database? Say your app is about matching people with the ice cream they like and you do not want to have your own db, that would need to be kept in synch with system contacts...
@CodeWithChris
@CodeWithChris 4 ай бұрын
Hello, thank you for taking the time to send us your inquiry! Unfortunately, we can't answer it for you in the comment section here, but you can try joining and posting in our community: cwc.to/codecrew --Joash
@allurisirisha3940
@allurisirisha3940 2 жыл бұрын
Help me in my demo project… suppose I want 5 view controllers in single app. Like, in first page is log in page . Second one our names. 3rd one our designation like iOS tutorial, 4th one some description about that designation…. This is my requirement. How can I write the code on that? Help me please….
@CodeWithChris
@CodeWithChris 2 жыл бұрын
Hello, post your question on our CodeCrew forum so that our tech support staff can assist you. Go here: codecrew.codewithchris.com. Thank you! -Arthur
@allurisirisha3940
@allurisirisha3940 2 жыл бұрын
I didn’t have an account in that. How can I access?
@FabricioMTL
@FabricioMTL Жыл бұрын
Hey Chris how can i have access to chat course
@CodeWithChris
@CodeWithChris Жыл бұрын
Hello Fabrice, you can find everything on www.codewithchris.com website. :) @AdrienVillez
@allurisirisha3940
@allurisirisha3940 2 жыл бұрын
Hai Chris….. how are you??
@CodeWithChris
@CodeWithChris 2 жыл бұрын
We're doing great, Alluri! -Arthur
@Jan-yf8qo
@Jan-yf8qo 2 жыл бұрын
Hi Chris, I love your videos and your tuts. They are great and I learned so much. But this lesson took me half a day to find a solution, why your code doesn't work on macOS. No errors in code but access to contacts wasn't granted and never asked and debugging with print(error.localizedDescription) always said: Access denied. For all having the same problem on macOS: go to project info in your project. Select "TARGETS" and choose the tab "Signing & Capabilities". There scroll down to "App Sandbox" and check App Data -> Contacts. Et voilá!
@CodeWithChris
@CodeWithChris 2 жыл бұрын
You are a great problem solver! Well done! -Arthur
@lamzika
@lamzika 2 жыл бұрын
This is amazing video with great works very well
@CodeWithChris
@CodeWithChris 2 жыл бұрын
Cheers, thank you! -Arthur
Data Flow in a SwiftUI App
33:15
CodeWithChris
Рет қаралды 53 М.
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 194 МЛН
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
Can A Seed Grow In Your Nose? 🤔
00:33
Zack D. Films
Рет қаралды 29 МЛН
Double Stacked Pizza @Lionfield @ChefRush
00:33
albert_cancook
Рет қаралды 118 МЛН
How to Make an App - Lesson 1 (2024 / SwiftUI)
27:21
CodeWithChris
Рет қаралды 399 М.
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
Why The Windows Phone Failed
24:08
Apple Explained
Рет қаралды 235 М.
How I Setup My iPhone - So It Doesn't Ruin My Life...
9:05
Tim Koa
Рет қаралды 1 МЛН
How Dual SIM on the iPhone Works
10:49
Jerad Hill Tech
Рет қаралды 958 М.
How to Become a Mobile App Developer in 2022
17:48
CodeWithChris
Рет қаралды 46 М.
Linus Torvalds: Speaks on Hype and the Future of AI
9:02
SavvyNik
Рет қаралды 126 М.
80 Year Olds Share Advice for Younger Self
12:22
Sprouht
Рет қаралды 1,7 МЛН
How to Make an App in 8 Days (2024) - Full Walkthrough
3:00:49
CodeWithChris
Рет қаралды 668 М.
How to Setup Firestore database for your SwiftUI app (2021)
26:32
CodeWithChris
Рет қаралды 25 М.
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 194 МЛН