Sauter au contenu

Getting Started

GitHub

Vous pouvez utiliser notre configuration assistée par l'IA pour installer le plugin. Ajoutez les Capgo compétences à votre outil IA en utilisant la commande suivante :

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

Ensuite, utilisez la prompt suivante :

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 la configuration manuelle, installez le plugin en exécutant les commandes suivantes et suivez les instructions spécifiques à la plateforme ci-dessous :

Fenêtre de terminal
bun add @capgo/capacitor-contacts
bunx cap sync
import { CapacitorContacts } from '@capgo/capacitor-contacts';

Comptez le nombre total de contacts sur le dispositif.

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

Créer un nouveau contact de manière programmée.

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 à l'aide du visionneur de contacts natif.

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

Display the native create contact UI.

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

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

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

Récupérer tous les comptes disponibles sur le dispositif.

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

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.

Récupérer tous les contacts du dispositif.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getContacts();
// The result holds sensitive values: use it without logging it.

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

Récupérer tous les groupes de contacts.

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

Vérifier si les contacts sont disponibles sur le dispositif.

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

Vérifier 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 du dispositif.

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

Sélectionnez un contact unique à l'aide du sélectionneur 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électionnez un ou plusieurs contacts à l'aide du sélectionneur de contacts natif.

import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContacts();
// The result holds sensitive values: use it without logging it.

Mettre à 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 des autorisations pour les contacts.

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

Demander les autorisations pour accéder aux contacts.

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

Résultat de comptage des contacts.

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

Options pour créer 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 son 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 utilisateur 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'>;
}

Result from displaying the native create contact UI.

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 for displaying the native update contact UI.

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 du plugin. src/definitions.tsRe-run the synchronisation lorsque le public API change en amont.

Continuez de l'étape de démarrage

Section intitulée “Continuez de l’Accueil”

Si vous utilisez Getting Started pour planifier votre tableau de bord et les opérations API, connectez-l’à Utilisez @capgo/capacitor-contacts pour la capacité native dans Utilisez @capgo/capacitor-contacts, API Vue d'ensemble pour le détail d'implémentation dans API Vue d'ensemble, Introduction pour le détail d'implémentation dans Introduction, API Clés pour le détail d'implémentation dans API Clés, et Appareils pour les détails d'implémentation dans Appareils.