Skip to content

Contacts Store

Stanislav Osipov edited this page Nov 7, 2020 · 4 revisions

The ISN_CNContactStore class is a thread-safe class that can fetch and save contacts, groups, and containers.

Fetch Phone Contacts

You may fetch all the contacts from user contact book with the FetchPhoneContacts of the ISN_CNContactStore class.

using SA.iOS.Contacts 
...
ISN_CNContactStore.FetchPhoneContacts((result) => {
    if(result.IsSucceeded) {
        foreach(var contact in result.Contacts) {
            Debug.Log(contact.GivenName);
        }
    } else {
        Debug.Log("Error: " + result.Error.Message);
    }
});

Notes field.

When fetching contacts you may choose if you would also like to request the CNContactNoteKey key. To do so, pass includeNotes parameter as true. The default value is false.

using SA.iOS.Contacts 
...
var includeNotes = true;
ISN_CNContactStore.FetchPhoneContacts((result) => {
    if(result.IsSucceeded) {
        foreach(var contact in result.Contacts) {
            Debug.Log(contact.GivenName);
        }
    } else {
        Debug.Log("Error: " + result.Error.Message);
    }
}, includeNotes); 

Since IOS 13 to be able to fetch the note property in iOS, your app needs the com.apple.developer.contacts.notes entitlement. Special thx to @chris-o3h for pointing that out.

About

Foundation

AV Foundation

App Tracking Transparency

Game Kit

Store Kit

UI Kit

Social

Replay Kit

Contacts

AVKit

Photos

App Delegate

User Notifications

MediaPlayer

Core Location

AdSupport

EventKit

CloudKit

Authentication Services

XCode

Knowledge Base

Clone this wiki locally