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.
Properties
Section titled “Properties”birthday
Section titled “birthday”Birthday.
birthday: DateDates.
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.
departmentName
Section titled “departmentName”Name of the department associated with the contact.
departmentName: stringemailAddresses
Section titled “emailAddresses”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.
familyName
Section titled “familyName”Family name.
familyName: stringgivenName
Section titled “givenName”Given name.
givenName: stringidentifier
Section titled “identifier”Uniquely identifies the contact on the device.
identifier: stringRead-only.
Profile picture.
image: ImageisBirthdayAvailable
Section titled “isBirthdayAvailable”Whether or not birthday is available.
isBirthdayAvailable: boolThe 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.
isDatesAvailable
Section titled “isDatesAvailable”Whether or not dates are available.
isDatesAvailable: boolThe 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.
isDepartmentNameAvailable
Section titled “isDepartmentNameAvailable”Whether or not department name is available.
isDepartmentNameAvailable: boolThe 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.
isEmailAddressesAvailable
Section titled “isEmailAddressesAvailable”Whether or not email addresses are available.
isEmailAddressesAvailable: boolThe 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.
isFamilyNameAvailable
Section titled “isFamilyNameAvailable”Whether or not family name is available.
isFamilyNameAvailable: boolThe 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.
isGiveNameAvailable
Section titled “isGiveNameAvailable”Whether or not given name is available.
isGiveNameAvailable: boolThe 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.
isImageAvailable
Section titled “isImageAvailable”Whether or not image is available.
isImageAvailable: boolThe 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.
isJobTitleAvailable
Section titled “isJobTitleAvailable”Whether or not job title is available.
isJobTitleAvailable: boolThe 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.
isMiddleNameAvailable
Section titled “isMiddleNameAvailable”Whether or not middle name is available.
isMiddleNameAvailable: boolThe 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.
isNamePrefixAvailable
Section titled “isNamePrefixAvailable”Whether or not name prefix is available.
isNamePrefixAvailable: boolThe 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.
isNicknameAvailable
Section titled “isNicknameAvailable”Whether or not nickname is available.
isNicknameAvailable: boolThe 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.
isNoteAvailable
Section titled “isNoteAvailable”Whether or not note is available.
isNoteAvailable: boolThe 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.
isOrganizationNameAvailable
Section titled “isOrganizationNameAvailable”Whether or not organization name is available.
isOrganizationNameAvailable: boolThe 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.
isPhoneNumbersAvailable
Section titled “isPhoneNumbersAvailable”Whether or not phone numbers are available.
isPhoneNumbersAvailable: boolThe 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.
isPostalAddressesAvailable
Section titled “isPostalAddressesAvailable”Whether or not postal addresses are available.
isPostalAddressesAvailable: boolThe 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.
isSocialProfilesAvailable
Section titled “isSocialProfilesAvailable”Whether or not social profiles are available.
isSocialProfilesAvailable: boolThe 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.
isURLAddressesAvailable
Section titled “isURLAddressesAvailable”Whether or not URL addresses are available.
isURLAddressesAvailable: boolThe 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.
jobTitle
Section titled “jobTitle”The contact’s job title.
jobTitle: stringmiddleName
Section titled “middleName”Middle name.
middleName: stringnamePrefix
Section titled “namePrefix”Name prefix.
namePrefix: stringnickname
Section titled “nickname”Nickname.
nickname: stringNote for the contact.
note: stringFor 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.
organizationName
Section titled “organizationName”Name of the organization associated with the contact.
organizationName: stringphoneNumbers
Section titled “phoneNumbers”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.
postalAddresses
Section titled “postalAddresses”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.
socialProfiles
Section titled “socialProfiles”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.
urlAddresses
Section titled “urlAddresses”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.
Methods
Section titled “Methods”
new Contact()
Section titled “new Contact()”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.
add(contact, containerIdentifier)
Section titled “add(contact, containerIdentifier)”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.
Parameters
Section titled “Parameters”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.
all(containers)
Section titled “all(containers)”Fetches contacts.
static all(containers: [ContactsContainer]): Promise<[Contact]>Fetches the contacts in the specified containers. A contact can be in only one container.
Parameters
Section titled “Parameters”containers [ContactsContainer]
Containers to fetch contacts from.
Return value
Section titled “Return value”Promise<[Contact]>
Promise that provides the contacts when fulfilled.
delete(contact)
Section titled “delete(contact)”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.
Parameters
Section titled “Parameters”contact Contact
Contact to queue to be deleted.
inGroups(groups)
Section titled “inGroups(groups)”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.
Parameters
Section titled “Parameters”groups [ContactsGroup]
Groups to fetch contacts from.
Return value
Section titled “Return value”Promise<[Contact]>
Promise that provides the contacts when fulfilled.
persistChanges()
Section titled “persistChanges()”Persist queued changes to the address book.
static persistChanges(): PromiseCall 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.
Return value
Section titled “Return value”Promise
Promise that fulfills when the changes have been persisted. The promise carries no value.
update(contact)
Section titled “update(contact)”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.
Parameters
Section titled “Parameters”contact Contact
Contact to queue to be updated.