Skip to content

Contact

Contact in the address book.

The type represents a contact in the address book. You can use the type to fetch and update contacts in the address book. If you are signed into multiple accounts on the device, you may have multiple sources that populate the address book. A source is is represented as a ContactsContainer. A contact may be in only one container. A CardDAV account usually has a single container whereas an Exchange account may have multiple containers.

Birthday.

birthday: Date

Dates.

dates: [{string: any}]

When updating this property, you must set the entire array of dates that you would like to store on the contact. The “identifier” key is optional.

Name of the department associated with the contact.

departmentName: string

Email addresses.

emailAddresses: [{string: string}]

An array of objects on the following form:

{
"identifier": "UUID-ABC-123",
"label": "Home",
"localizedLabel": "Home",
"value": "my@example.com"
}

The identifier uniquely identifies the email address on this device. The label is a description of the email address and the value holds the email address itself.

When updating this property, you must set the entire array of email addresses that you would like to store on the contact. Each value in the array must have the “value” key. The other keys are optional.

Family name.

familyName: string

Given name.

givenName: string

Uniquely identifies the contact on the device.

identifier: string

Read-only.

Profile picture.

image: Image

Whether or not birthday is available.

isBirthdayAvailable: bool

The birthday property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not dates are available.

isDatesAvailable: bool

The date property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not department name is available.

isDepartmentNameAvailable: bool

The departmentName property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not email addresses are available.

isEmailAddressesAvailable: bool

The emailAddresses property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not family name is available.

isFamilyNameAvailable: bool

The familyName property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not given name is available.

isGiveNameAvailable: bool

The givenName property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not image is available.

isImageAvailable: bool

The image property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not job title is available.

isJobTitleAvailable: bool

The jobTitle property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not middle name is available.

isMiddleNameAvailable: bool

The middleName property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not name prefix is available.

isNamePrefixAvailable: bool

The namePrefix property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not nickname is available.

isNicknameAvailable: bool

The nickname property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not note is available.

isNoteAvailable: bool

The note property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Notes are not available on contacts starting from version 1.7.5.

Read-only.

Whether or not organization name is available.

isOrganizationNameAvailable: bool

The organizationName property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not phone numbers are available.

isPhoneNumbersAvailable: bool

The phoneNumbers property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not postal addresses are available.

isPostalAddressesAvailable: bool

The postalAddresses property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not social profiles are available.

isSocialProfilesAvailable: bool

The socialProfiles property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

Whether or not URL addresses are available.

isURLAddressesAvailable: bool

The urlAddresses property may not be available if the container does not support it. In that case any value set on the property will be ignored.

Read-only.

The contact’s job title.

jobTitle: string

Middle name.

middleName: string

Name prefix.

namePrefix: string

Nickname.

nickname: string

Note for the contact.

note: string

For security reasons, a contact’s notes cannot be accessed in Siri, the Shortcuts app and in a notification.

Notes are not available on contacts starting from version 1.7.5.

Name of the organization associated with the contact.

organizationName: string

Phone numbers.

phoneNumbers: [{string: string}]

An array of objects on the following form:

{
"identifier": "UUID-ABC-123",
"label": "Home",
"localizedLabel": "Home",
"value": "(111)234-5678"
}

The identifier uniquely identifies the phone number on this device. The label is a description of the phone number and the value holds the phone number itself.

When updating this property, you must set the entire array of phone numbers that you would like to store on the contact. Each value in the array must have the “value” key. The other keys are optional.

Postal addresses.

postalAddresses: [{string: string}]

An array of objects on the following form:

{
"identifier": "UUID-ABC-123",
"label": "Home",
"localizedLabel": "Home",
"street": "240 Terry Lane",
"city": "New York",
"state": "New York",
"postalCode": "10001",
"country": "United States of America"
}

The identifier uniquely identifies the pstal address on this device. The label is a description of the phone number and the value holds the phone number itself.

When updating this property, you must set the entire array of postal addresses that you would like to store on the contact. The “identifier” key is optional.

Social profiles.

socialProfiles: [{string: string}]

An array of objects on the following form:

{
"identifier": "UUID-ABC-123",
"label": "Twitter",
"localizedLabel": "Twitter",
"service": "Twitter",
"url": "https://twitter.com/scriptableapp",
"userIdentifier": null,
"username": "scriptableapp"
}

The identifier uniquely identifies the social profile on this device. The label is a description of the social profile, the service is the social profile’s service name, the URL contains a link to the social profile, the userIdentifier is the identifier of the social profile and the username is the name for the social profile.

When updating this property, you must set the entire array of social profiles that you would like to store on the contact. The “identifier” key is optional.

URL addresses.

urlAddresses: [{string: string}]

When updating this property, you must set the entire array of URL addresses that you would like to store on the contact. The “identifier” key is optional.

Constructs a contact.

new Contact()

In order to add the contact to your address book, you must queue it for insertion using Contact.add(). When you’re done making changes to the address book you should call Contact.persistChanges() to persist the changes.

Queues a contact to be added.

static add(contact: Contact, containerIdentifier: string)

After you have created a contact, you must queue the contact to be added to the address book and invoke Contact.persistChanges() to persist the changes to the address book.

For performance reasons, it is best to batch changes to the address book. Therefore you should queue all updates, insertions and removals of contacts and contacts groups to as large batches as possible and then call Contact.persistChanges() when you want to persist the changes to the address book.

contact Contact

Contact to queue to be added.

containerIdentifier string

Optional. Identifier of container to add the contact to. If null is specified, the contact will be added to the default container.

Fetches contacts.

static all(containers: [ContactsContainer]): Promise<[Contact]>

Fetches the contacts in the specified containers. A contact can be in only one container.

containers [ContactsContainer]

Containers to fetch contacts from.

Promise<[Contact]>

Promise that provides the contacts when fulfilled.

Queues a contact to be deleted.

static delete(contact: Contact)

To delete a contact, you must queue the contact for deletion and invoke Contact.persistChanges() to persist the changes to the address book.

For performance reasons, it is best to batch changes to the address book. Therefore you should queue all updates, insertions and removals of contacts and contacts groups to as large batches as possible and then call Contact.persistChanges() when you want to persist the changes to the address book.

contact Contact

Contact to queue to be deleted.

Fetches contacts in groups.

static inGroups(groups: [ContactsGroup]): Promise<[Contact]>

Fetches the contacts in the specified contacts groups. A contact may belong to many groups.

groups [ContactsGroup]

Groups to fetch contacts from.

Promise<[Contact]>

Promise that provides the contacts when fulfilled.

Persist queued changes to the address book.

static persistChanges(): Promise

Call this function to persist changes queued with Contact.add(), Contact.update() and Contact.delete().

For performance reasons, it is best to batch changes to the address book. Therefore you should queue all updates, insertions and removals of contacts and contacts groups to as large batches as possible and then call Contact.persistChanges() when you want to persist the changes to the address book.

Promise

Promise that fulfills when the changes have been persisted. The promise carries no value.

Queues an update to a contact.

static update(contact: Contact)

After you have updated one or more properties on a contact, you must queue the contact to be updated and invoke Contact.persistChanges() to persist the changes to the address book.

For performance reasons, it is best to batch changes to the address book. Therefore you should queue all updates, insertions and removals of contacts and contacts groups to as large batches as possible and then call Contact.persistChanges() when you want to persist the changes to the address book.

contact Contact

Contact to queue to be updated.