Aller au contenu

Prise en main

GitHub

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 :

Fenêtre de terminal
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Utilisez 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 :

Fenêtre de terminal
npm install @capgo/capacitor-contacts
npx cap sync
import { CapacitorContacts } from '@capgo/capacitor-contacts';

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.
  • Justification: explain why contacts access is needed before the dialog.
  • Pagination: évitez de charger tout le carnet d’adresses d’un coup.
  • Écrit: la création de contacts nécessite l’autorisation d’écriture.

Compter le nombre total de contacts sur l'appareil.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.countContacts();
console.log(result);

Créer un nouveau contact par programmation.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createContact({ contact: {} });
console.log(result);

Créer un nouveau groupe de contacts.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createGroup({ group: { name: 'example' } });
console.log(result);

Supprimer un contact par son ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteContactById({ id: 'id-123' });

Supprimer un groupe par son ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteGroupById({ id: 'id-123' });

Afficher un contact via le visualiseur de contacts natif.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayContactById({ id: 'id-123' });

Afficher l'interface native de création de contact.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.displayCreateContact();
console.log(result);

Affiche l'interface native de mise à jour de contact pour un contact spécifique.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayUpdateContactById({ id: 'id-123' });

Récupère tous les comptes disponibles sur l'appareil.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getAccounts();
console.log(result);

Récupère 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.

Récupère 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.

Récupère un groupe spécifique par son ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroupById({ id: 'id-123' });
console.log(result);

Récupère tous les groupes de contacts.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroups();
console.log(result);

Vérifie si les contacts sont disponibles sur l'appareil.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isAvailable();
console.log(result);

Vérifie si le plugin est pris en charge sur la plateforme actuelle.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isSupported();
console.log(result);

Ouvrez les paramètres de contacts de l’appareil.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.openSettings();

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.

Sélectionne 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.

Met à jour un contact existant par son ID.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.updateContactById({
id: 'id-123',
contact: {},
});

Vérifiez l'état actuel de l'autorisation pour les contacts.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.checkPermissions();
console.log(result);

Demandez les autorisations pour accéder aux contacts.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.requestPermissions();
console.log(result);

Résultat du comptage des contacts.

export interface CountContactsResult {
/**
* Total number of contacts.
*
* @since 1.0.0
*/
count: number;
}

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'>;
}

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;
}

Options pour créer un groupe.

export interface CreateGroupOptions {
/**
* Group information to create. The 'id' field will be generated automatically.
*
* @since 1.0.0
*/
group: Omit<Group, 'id'>;
}

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;
}

Options pour supprimer un contact par ID.

export interface DeleteContactByIdOptions {
/**
* The ID of the contact to delete.
*
* @since 1.0.0
*/
id: string;
}

Options pour supprimer un groupe par ID.

export interface DeleteGroupByIdOptions {
/**
* The ID of the group to delete.
*
* @since 1.0.0
*/
id: string;
}

Options pour afficher un contact par ID.

export interface DisplayContactByIdOptions {
/**
* The ID of the contact to display.
*
* @since 1.0.0
*/
id: string;
}

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'>;
}

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;
}

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;
}

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[];
}

Cette page est générée à partir de src/definitions.ts. Relancez la synchronisation lorsque l’API public change en amont.

Si vous utilisez Prise en main pour planifier les opérations du dashboard et de API, connectez-l’avec Utiliser @capgo/capacitor-contacts pour la fonctionnalité native dans « Utiliser @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.