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.

identifier

Uniquely identifies the contact on the device.

identifier: string

namePrefix

Name prefix.

namePrefix: string

givenName

Given name.

givenName: string

middleName

Middle name.

middleName: string

familyName

Family name.

familyName: string

nickname

Nickname.

nickname: string

birthday

Birthday.

birthday: Date

image

Profile picture.

image: Image

emailAddresses

Email addresses.

An array of objects on the following form:

{
  "identifier": "UUID-ABC-123",
  "label": "Home",
  "localizedLabel": "Home",
  "value": "[email protected]"
}

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.

emailAddresses: [{string: string}]

phoneNumbers

Phone numbers.

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.

phoneNumbers: [{string: string}]

postalAddresses

Postal addresses.

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 phone number on this device. The label is a description of the phone number and the value holds the phone number itself.

postalAddresses: [{string: string}]

socialProfiles

Social profiles.

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.

socialProfiles: [{string: string}]

note

Note for the contact.

note: string

urlAddresses

URL addresses.

urlAddresses: string

organizationName

Name of the organization associated with the contact.

organizationName: string

departmentName

Name of the department associated with the contact.

departmentName: string

jobTitle

The contact's job title.

jobTitle: string

-new Contact

Constructs a 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.

new Contact()

+all

Fetches contacts.

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

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

+inGroups

Fetches contacts in groups.

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

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

+add

Queues a contact to be added.

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.

static add(contact: Contact, containerIdentifier: string)

+update

Queues an update to a 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.

static update(contact: Contact)

+delete

Queues a contact to be deleted.

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.

static delete(contact: Contact)

+persistChanges

Persist queued changes to the address book.

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.

static persistChanges(): Promise