Prise en main
Copiez un prompt de configuration incluant les étapes d'installation et le guide markdown complet pour ce plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-contacts`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/contacts/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Installer
Section intitulée « Installation »Vous pouvez utiliser notre configuration assistée par IA pour installer le plugin. Ajoutez les skills Capgo à votre outil d'IA avec la commande suivante :
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsUtilisez ensuite le prompt suivant :
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-contacts` plugin in my project.Si vous préférez une installation manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à chaque plateforme ci-dessous :
npm install @capgo/capacitor-contactsnpx cap syncImporter
Section intitulée « Import »import { CapacitorContacts } from '@capgo/capacitor-contacts';Démarrage rapide
Section intitulée « Démarrage rapide »Demandez l'accès, puis chargez les contacts avec une taille de page adaptée plutôt que tout le carnet d'adresses.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.requestPermissions();const { contacts } = await CapacitorContacts.getContacts({ limit: 50, offset: 0 });// Increase offset by limit for the next page instead of loading the full address book.Erreurs courantes
Section intitulée « Erreurs courantes »- Rationale: explain why contacts access is needed before the dialog.
- Pagination: évitez de charger l'intégralité du répertoire d'un coup.
- Écritures: la création de contacts nécessite une permission d'écriture.
Aperçu de API
Section intitulée « Aperçu API »countContacts
Section intitulée « countContacts »Compte le nombre total de contacts sur l'appareil.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.countContacts();console.log(result);createContact
Section intitulée « createContact »Créer un nouveau contact par programmation.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createContact({ contact: {} });console.log(result);createGroup
Section intitulée « createGroup »Créer un nouveau groupe de contacts.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createGroup({ group: { name: 'example' } });console.log(result);deleteContactById
Section intitulée « deleteContactById »Supprimer un contact par son ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteContactById({ id: 'id-123' });deleteGroupById
Section intitulée « deleteGroupById »Supprimer un groupe par son ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteGroupById({ id: 'id-123' });displayContactById
Section intitulée « displayContactById »Affichez un contact en utilisant le visualiseur de contacts natif.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayContactById({ id: 'id-123' });displayCreateContact
Section intitulée « displayCreateContact »Affichez l'interface native de création de contact.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.displayCreateContact();console.log(result);displayUpdateContactById
Section intitulée « displayUpdateContactById »Affichez l'interface native de modification pour un contact spécifique.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayUpdateContactById({ id: 'id-123' });getAccounts
Section intitulée « getAccounts »Récupérez tous les comptes disponibles sur l'appareil.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getAccounts();console.log(result);getContactById
Section intitulée « getContactById »Récupérer un contact spécifique par son ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getContactById({ id: 'id-123' });// The result holds sensitive values: use it without logging it.getContacts
Section intitulée « getContacts »Récupérer tous les contacts de l'appareil.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getContacts();// The result holds sensitive values: use it without logging it.getGroupById
Section intitulée « getGroupById »Récupérer un groupe spécifique par son ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroupById({ id: 'id-123' });console.log(result);getGroups
Section intitulée « getGroups »Récupérer tous les groupes de contacts.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroups();console.log(result);isAvailable
Section intitulée « isAvailable »Vérifie si les contacts sont disponibles sur l'appareil.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isAvailable();console.log(result);isSupported
Section intitulée « isSupported »Vérifie si le plugin est supporté sur la plateforme actuelle.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isSupported();console.log(result);openSettings
Section intitulée « openSettings »Ouvre les paramètres de contacts de l'appareil.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.openSettings();pickContact
Section intitulée « pickContact »Sélectionne un contact via le sélecteur de contacts natif.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContact();// The result holds sensitive values: use it without logging it.pickContacts
Section intitulée « pickContacts »Sélectionnez un ou plusieurs contacts via le sélecteur de contacts natif.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContacts();// The result holds sensitive values: use it without logging it.updateContactById
Section intitulée « updateContactById »Mettez à jour un contact existant par son ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.updateContactById({ id: 'id-123', contact: {},});checkPermissions
Section intitulée « checkPermissions »Vérifiez l'état actuel des permissions pour les contacts.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.checkPermissions();console.log(result);requestPermissions
Section intitulée « requestPermissions »Demandez les permissions pour accéder aux contacts.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.requestPermissions();console.log(result);Référence de type
Section intitulée « Référence des types »CountContactsResult
Section intitulée « CountContactsResult »Résultat du comptage des contacts.
export interface CountContactsResult { /** * Total number of contacts. * * @since 1.0.0 */ count: number;}CreateContactOptions
Section intitulée « CreateContactOptions »Options pour la création d'un contact.
export interface CreateContactOptions { /** * Contact information to create. The 'id' field will be generated automatically. * * @since 1.0.0 */ contact: Omit<Contact, 'id'>;}CreateContactResult
Section intitulée « CreateContactResult »Résultat de la création d'un contact.
export interface CreateContactResult { /** * The ID of the newly created contact. * * @since 1.0.0 */ id: string;}CreateGroupOptions
Section intitulée « CreateGroupOptions »Options pour la création d'un groupe.
export interface CreateGroupOptions { /** * Group information to create. The 'id' field will be generated automatically. * * @since 1.0.0 */ group: Omit<Group, 'id'>;}CreateGroupResult
Section intitulée « CreateGroupResult »Résultat de la création d'un groupe.
export interface CreateGroupResult { /** * The ID of the newly created group. * * @since 1.0.0 */ id: string;}DeleteContactByIdOptions
Section intitulée « DeleteContactByIdOptions »Options pour supprimer un contact par son ID.
export interface DeleteContactByIdOptions { /** * The ID of the contact to delete. * * @since 1.0.0 */ id: string;}DeleteGroupByIdOptions
Section intitulée « DeleteGroupByIdOptions »Options pour supprimer un groupe par son ID.
export interface DeleteGroupByIdOptions { /** * The ID of the group to delete. * * @since 1.0.0 */ id: string;}DisplayContactByIdOptions
Section intitulée « DisplayContactByIdOptions »Options pour afficher un contact par ID.
export interface DisplayContactByIdOptions { /** * The ID of the contact to display. * * @since 1.0.0 */ id: string;}DisplayCreateContactOptions
Section intitulée « DisplayCreateContactOptions »Options pour afficher l'interface native de création de contact.
export interface DisplayCreateContactOptions { /** * Optional pre-filled contact information for the create UI. * * @since 1.0.0 */ contact?: Omit<Contact, 'id'>;}DisplayCreateContactResult
Section intitulée « DisplayCreateContactResult »Résultat de l'affichage de l'interface native de création de contact.
export interface DisplayCreateContactResult { /** * The ID of the created contact, if one was created. Undefined if the user cancelled. * * @since 1.0.0 */ id?: string;}DisplayUpdateContactByIdOptions
Section intitulée « DisplayUpdateContactByIdOptions »Options pour afficher l'interface native de mise à jour de contact.
export interface DisplayUpdateContactByIdOptions { /** * The ID of the contact to update. * * @since 1.0.0 */ id: string;}GetAccountsResult
Section intitulée « GetAccountsResult »Résultat de la récupération des comptes.
export interface GetAccountsResult { /** * List of accounts available on the device. * * @since 1.0.0 */ accounts: Account[];}Source de vérité
Section intitulée « Source de vérité »Cette page est générée à partir de src/definitions.ts. Relancez la synchronisation quand l’API public change en amont.
Continuer depuis Getting Started
Section intitulée « Continuer après Prise en main »Si vous utilisez Prise en main pour planifier les opérations du dashboard et de API, connectez-l’avec Utilisation de @capgo/capacitor-contacts pour la capacité native dans l'utilisation de @capgo/capacitor-contacts, Aperçu de API pour les détails d'implémentation dans « Vue d'ensemble de API », Introduction pour les détails d'implémentation dans l'introduction, Clés API pour les détails d'implémentation dans « Clés API », et Appareils pour les détails d'implémentation dans Devices.