From axiom
Guides iOS Contacts access: authorization levels, picker vs store, Contact Access Button, permissions, iOS 18 limited access, incremental sync.
npx claudepluginhub charleswiltgen/axiom --plugin axiomThis skill uses the workspace's default tool permissions.
> "The contact access button is a powerful new way to manage access to contacts, right in your app. Instead of a full-screen picker, this button fits into your existing UI."
Provides Ktor server patterns for routing DSL, plugins (auth, CORS, serialization), Koin DI, WebSockets, services, and testApplication testing.
Conducts multi-source web research with firecrawl and exa MCPs: searches, scrapes pages, synthesizes cited reports. For deep dives, competitive analysis, tech evaluations, or due diligence.
Provides demand forecasting, safety stock optimization, replenishment planning, and promotional lift estimation for multi-location retailers managing 300-800 SKUs.
"The contact access button is a powerful new way to manage access to contacts, right in your app. Instead of a full-screen picker, this button fits into your existing UI."
Mental model: Contacts has four authorization levels. Most apps should use the Contact Access Button or CNContactPickerViewController, which require no authorization at all. Only request store access when you need persistent contact data.
Use this skill when:
Do NOT use this skill for:
digraph contacts_access {
rankdir=TB;
"What does your app need?" [shape=diamond];
"One-time contact selection?" [shape=diamond];
"Persistent access to specific contacts?" [shape=diamond];
"Search + incremental discovery?" [shape=diamond];
"Read entire contact database?" [shape=diamond];
"CNContactPickerViewController" [shape=box, label="No Auth Required\nCNContactPickerViewController\nOne-time snapshot"];
"Contact Access Button" [shape=box, label="Limited or Not Determined\nContactAccessButton\nGrants access per-contact"];
"contactAccessPicker" [shape=box, label="Limited Access\ncontactAccessPicker\nBulk contact selection"];
"Full access" [shape=box, label="Full Access\nCNContactStore\nRead/write all contacts"];
"What does your app need?" -> "One-time contact selection?" [label="pick a contact"];
"One-time contact selection?" -> "CNContactPickerViewController" [label="yes"];
"One-time contact selection?" -> "Persistent access to specific contacts?" [label="no, need persistent"];
"Persistent access to specific contacts?" -> "Search + incremental discovery?" [label="yes"];
"Search + incremental discovery?" -> "Contact Access Button" [label="search flow\n(best UX)"];
"Search + incremental discovery?" -> "contactAccessPicker" [label="bulk selection\n(friend matching)"];
"Persistent access to specific contacts?" -> "Read entire contact database?" [label="no"];
"Read entire contact database?" -> "Full access" [label="yes, core feature"];
}
App hasn't requested access yet. CNContactStore auto-prompts on first access attempt. ContactAccessButton works in this state — tapping it triggers a simplified limited-access prompt.
User selected specific contacts to share. Your app sees only those contacts via CNContactStore. The API surface is identical to full access — only the visible contacts differ.
Your app always has access to contacts it creates, regardless of authorization level.
Read/write access to all contacts. Users must explicitly choose "Full Access" in the two-stage prompt. Reserve this for apps where contacts are the core feature.
No access to contact data. App cannot read, write, or enumerate contacts.
The preferred way to give users control over which contacts your app can access. Shows search results for contacts your app doesn't yet have access to. One tap grants access.
@State private var searchText = ""
var body: some View {
VStack {
// Your app's own search results first
ForEach(myAppResults) { result in
ContactRow(result)
}
// Contact Access Button for contacts not yet shared
if authStatus == .limited || authStatus == .notDetermined {
ContactAccessButton(queryString: searchText) { identifiers in
let contacts = await fetchContacts(withIdentifiers: identifiers)
// Use the newly accessible contacts
}
}
}
}
ContactAccessButton(queryString: searchText)
.font(.system(weight: .bold)) // Upper text + action label
.foregroundStyle(.gray) // Primary text color
.tint(.green) // Action label color
.contactAccessButtonCaption(.phone) // .defaultText, .email, .phone
.contactAccessButtonStyle(
ContactAccessButton.Style(imageWidth: 30)
)
The button only grants access when:
If any requirement fails, tapping the button does nothing. Always ensure adequate contrast and avoid clipping.
| Pattern | Time Cost | Why It's Wrong | Fix |
|---|---|---|---|
| Requesting full access for contact picking | 1-2 sprint days recovering denied users | Full access prompts denied 40%+ of the time | Use CNContactPickerViewController or ContactAccessButton |
| Accessing unfetched key on CNContact | 15-30 min debugging crash | CNContactPropertyNotFetchedException — no clear error message | Always specify keysToFetch |
| Using manual name key lists instead of formatter descriptor | 10-20 min debugging per locale | Different cultures use different name field combinations | Use CNContactFormatter.descriptorForRequiredKeys(for:) |
| Creating multiple CNContactStore instances | 30+ min debugging stale data | Objects from one store can't be used with another | Create one, reuse it |
| Fetching all keys "just in case" | App Store review risk | Overfetching triggers stricter privacy scrutiny | Fetch only the keys you need |
Using CNContactStore on main thread | 1-2 hours debugging UI freezes | "Fetch methods perform I/O" — Apple docs | Run fetches on background thread |
Missing NSContactsUsageDescription in Info.plist | 15 min debugging crash | App crashes on any contact store access attempt | Add the usage description |
| Mutating CNMutableContact across threads | 2-4 hours debugging corruption | "CNMutableContact objects are not thread-safe" | Use immutable CNContact for cross-thread access |
Ignoring .limited status | 1-2 hours debugging "missing contacts" | App assumes full access but only sees subset | Check status and show ContactAccessButton |
Not handling note field entitlement | 30 min debugging empty notes | com.apple.developer.contacts.notes required | Apply for entitlement from Apple |
Always specify exactly which properties you need:
let keys: [CNKeyDescriptor] = [
CNContactGivenNameKey as CNKeyDescriptor,
CNContactFamilyNameKey as CNKeyDescriptor,
CNContactPhoneNumbersKey as CNKeyDescriptor,
CNContactFormatter.descriptorForRequiredKeys(for: .fullName)
]
let request = CNContactFetchRequest(keysToFetch: keys)
Rule: You may only modify properties whose values you fetched. Accessing an unfetched property throws CNContactPropertyNotFetchedException.
See contacts-ref for search predicates, save operations, name formatting, and vCard serialization.
For apps that cache contacts and need to detect changes:
// Save the token after initial fetch
var changeToken = store.currentHistoryToken
// Later, fetch changes since last token
let request = CNChangeHistoryFetchRequest()
request.startingToken = changeToken
request.shouldUnifyResults = true
request.additionalContactKeyDescriptors = [
CNContactFormatter.descriptorForRequiredKeys(for: .fullName)
]
// Process via visitor pattern (required)
class MyVisitor: NSObject, CNChangeHistoryEventVisitor {
func visit(_ event: CNChangeHistoryDropEverythingEvent) {
// Full re-sync needed — token expired or first fetch
}
func visit(_ event: CNChangeHistoryAddContactEvent) {
// New contact added
}
func visit(_ event: CNChangeHistoryUpdateContactEvent) {
// Contact modified
}
func visit(_ event: CNChangeHistoryDeleteContactEvent) {
// Contact deleted
}
}
Gotcha: enumeratorForChangeHistoryFetchRequest:error: is Objective-C only — unavailable in Swift. Use a bridging wrapper.
Token expiration: When token expires, the system returns a DropEverything event followed by Add events for all contacts. Same code path handles full and incremental sync.
Expose your app's contact graph to the system Contacts ecosystem.
// In main app: enable and signal
let manager = try ContactProviderManager(domainIdentifier: "com.myapp.contacts")
try await manager.enable() // May prompt user authorization
try await manager.signalEnumerator() // Trigger sync when data changes
// In extension
@main
class Provider: ContactProviderExtension {
func configure(for domain: ContactProviderDomain) { /* setup */ }
func enumerator(for collection: ContactItem.Identifier) -> ContactItemEnumerator {
return MyEnumerator()
}
func invalidate() async throws { /* cleanup */ }
}
Requires: App Group for data sharing between app and extension.
Pressure: PM wants full Contacts access for autocomplete.
Why resist: ContactAccessButton provides exactly this — search results for contacts the app doesn't have, one-tap to grant access. No scary full-access prompt.
Response: "ContactAccessButton gives us search-driven contact discovery without asking for full access. Users grant access to exactly the contacts they want to share, one at a time. Denial rate drops from 40%+ to near zero."
Pressure: Developer fetches all contact keys "to be safe."
Why resist: Overfetching contacts data is both a privacy concern (triggers stricter Apple review) and a performance problem (slower fetches, more memory).
Response: "Fetching only the keys we display means faster queries and less privacy exposure. Use CNContactFormatter.descriptorForRequiredKeys(for:) for name display — it handles all locale variations."
Pressure: Team sticks with picker because it's familiar.
Why resist: Picker gives one-time snapshots — the contacts are not persistently accessible. If you need to store or sync the contact, you need persistent access through ContactAccessButton or full authorization.
Response: "Picker works for one-time actions (share a phone number). But if we need to remember the contact (friend list, favorites), we need ContactAccessButton for persistent limited access."
When updating an app for iOS 18 limited access:
authorizationStatus(for: .contacts) for .limited caseContactAccessButton to contact search flowscontactAccessPicker for bulk access management if neededkeysToFetch is minimal — limited access doesn't change key behaviorWWDC: 2024-10121
Docs: /contacts, /contactsui, /contactprovider, /technotes/tn3149
Skills: contacts-ref, eventkit, privacy-ux