macotron.contacts
List and search the people in the Contacts app, with their names, company, email addresses, and phone numbers.
const [person] = await macotron.contacts.search("ada");
if (person && person.emails[0]) macotron.url.open("mailto:" + person.emails[0]);
People
Both calls read every contact in every account and run off the main thread. Each row has the same fields:
| Field | Meaning |
|---|---|
id | The contact's identifier. |
name | The full name, formatted the way Contacts shows it. "" for a contact with no name, such as a company card. |
first, last | The given name and family name. |
organization | The company name, or "". |
emails | Every email address, in card order. |
phones | Every phone number, as typed on the card. |
list(): Promise<Array<{ id, name, first, last, organization, emails, phones }>>
Every contact.
search(query: string): Promise<Array<{ id, name, first, last, organization, emails, phones }>>
Contacts whose name, organization, email addresses, or phone numbers contain query. The match ignores case and accents, so "jose" finds José. An empty query returns every contact.
Macotron needs Contacts access. The first call asks macOS to show the permission prompt and resolves with [] while the user decides. If access is denied, every call resolves with []; turn it on in System Settings → Privacy & Security → Contacts.
See also
- macotron.url to open
mailto:andtel:links. - macotron.launcher to put people in the launcher.
- The
contacts.jsplugin.