import { exec } from "child_process"; export interface Contact { /** * The name of the contact * @example "John Doe" */ name: string; /** * The number of the contact * @example "+421910123456" or "0910123456" or "4ka" */ number: string; } /** * List all contacts * * **Requires permission:** `android.permission.READ_CONTACTS` */ export async function contactList(): Promise { return new Promise((resolve, reject) => { const command = "termux-contact-list"; exec(command, (error, stdout, stderr) => { if (error) { return reject(`Error: ${error.message}`); } if (stderr) { return reject(`Error: ${stderr}`); } const output = stdout.trim(); const contacts: Contact[] = JSON.parse(output); return resolve(contacts); }); }); }