Erste Schritte
Kopiere einen Setup-Prompt mit den Installationsschritten und dem vollständigen Markdown-Guide für dieses 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.
Installieren
Abschnitt mit dem Titel „Installation“Du kannst unser KI-gestütztes Setup nutzen, um das Plugin zu installieren. Füge deinem KI-Tool die Capgo Skills mit folgendem Befehl hinzu:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsNutze anschließend diesen Prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-contacts` plugin in my project.Wenn du ein manuelles Setup bevorziehst, installiere das Plugin mit den folgenden Befehlen und befolge die plattformspezifischen Anweisungen unten:
npm install @capgo/capacitor-contactsnpx cap syncImportieren
Abschnitt mit dem Titel „Import“import { CapacitorContacts } from '@capgo/capacitor-contacts';Quickstart
Abschnitt mit dem Titel „Quickstart“Zugriff anfordern und Kontakte dann mit einer sinnvollen Seitengröße laden, statt das gesamte Adressbuch auf einmal.
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.Häufige Fehlerquellen
Abschnitt mit dem Titel „Häufige Fehlerquellen“- Begründung: Erkläre, warum Kontaktzugriff nötig ist, bevor der Dialog erscheint.
- Pagination: Vermeide es, alle Adressbücher auf einmal zu laden.
- Writes: Das Anlegen von Kontakten erfordert Schreibberechtigung.
API Übersicht
Abschnitt mit dem Titel „API Übersicht“countContacts
Abschnitt mit dem Titel „countContacts“Zählt die Gesamtzahl der Kontakte auf dem Gerät.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.countContacts();console.log(result);createContact
Abschnitt mit dem Titel „createContact“Erstellt programmatisch einen neuen Kontakt.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createContact({ contact: {} });console.log(result);createGroup
Abschnitt mit dem Titel „createGroup“Erstelle eine neue Kontaktgruppe.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createGroup({ group: { name: 'example' } });console.log(result);deleteContactById
Abschnitt mit dem Titel „deleteContactById“Lösche einen Kontakt anhand der ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteContactById({ id: 'id-123' });deleteGroupById
Abschnitt mit dem Titel „deleteGroupById“Lösche eine Gruppe anhand der ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteGroupById({ id: 'id-123' });displayContactById
Abschnitt „displayContactById“Zeigt einen Kontakt über den nativen Kontakt-Viewer an.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayContactById({ id: 'id-123' });displayCreateContact
Abschnitt „displayCreateContact“Öffnet das native UI zum Erstellen eines Kontakts.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.displayCreateContact();console.log(result);displayUpdateContactById
Abschnitt „displayUpdateContactById“Öffnet das native UI zum Bearbeiten eines spezifischen Kontakts.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayUpdateContactById({ id: 'id-123' });getAccounts
Abschnitt „getAccounts“Ruft alle auf dem Gerät verfügbaren Accounts ab.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getAccounts();console.log(result);getContactById
Abschnitt „getContactById“Einen bestimmten Kontakt per ID abrufen.
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
Abschnitt „getContacts“Alle Kontakte vom Gerät abrufen.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getContacts();// The result holds sensitive values: use it without logging it.getGroupById
Abschnitt „getGroupById“Eine bestimmte Gruppe per ID abrufen.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroupById({ id: 'id-123' });console.log(result);getGroups
Abschnitt „getGroups“Alle Kontaktgruppen abrufen.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.getGroups();console.log(result);isAvailable
Abschnitt „isAvailable“Prüfen, ob Kontakte auf dem Gerät verfügbar sind.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isAvailable();console.log(result);isSupported
Abschnitt „isSupported“Prüfen, ob das Plugin auf der aktuellen Plattform unterstützt wird.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.isSupported();console.log(result);openSettings
Abschnitt mit dem Titel „openSettings“Die Kontakt-Einstellungen des Geräts öffnen.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.openSettings();pickContact
Abschnitt mit dem Titel „pickContact“Einen einzelnen Kontakt über den nativen Contact Picker auswählen.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContact();// The result holds sensitive values: use it without logging it.pickContacts
Abschnitt „pickContacts“Einen oder mehrere Kontakte über den nativen Contact Picker auswählen.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.pickContacts();// The result holds sensitive values: use it without logging it.updateContactById
Abschnitt „updateContactById“Einen bestehenden Kontakt per ID aktualisieren.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.updateContactById({ id: 'id-123', contact: {},});checkPermissions
Abschnitt mit dem Titel „checkPermissions“Den aktuellen Berechtigungsstatus für Kontakte prüfen.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.checkPermissions();console.log(result);requestPermissions
Abschnitt mit dem Titel „requestPermissions“Zugriffsberechtigungen für Kontakte anfordern.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.requestPermissions();console.log(result);Typ-Referenz
Abschnitt mit dem Titel „Type Reference“CountContactsResult
Abschnitt „CountContactsResult“Ergebnis der Kontaktzählung.
export interface CountContactsResult { /** * Total number of contacts. * * @since 1.0.0 */ count: number;}CreateContactOptions
Abschnitt „CreateContactOptions“Optionen zum Erstellen eines Kontakts.
export interface CreateContactOptions { /** * Contact information to create. The 'id' field will be generated automatically. * * @since 1.0.0 */ contact: Omit<Contact, 'id'>;}CreateContactResult
Abschnitt „CreateContactResult“Ergebnis der Kontakterstellung.
export interface CreateContactResult { /** * The ID of the newly created contact. * * @since 1.0.0 */ id: string;}CreateGroupOptions
Abschnitt „CreateGroupOptions“Optionen zum Erstellen einer Gruppe.
export interface CreateGroupOptions { /** * Group information to create. The 'id' field will be generated automatically. * * @since 1.0.0 */ group: Omit<Group, 'id'>;}CreateGroupResult
Abschnitt mit dem Titel „CreateGroupResult“Ergebnis der Gruppenerstellung.
export interface CreateGroupResult { /** * The ID of the newly created group. * * @since 1.0.0 */ id: string;}DeleteContactByIdOptions
Abschnitt „DeleteContactByIdOptions“Optionen zum Löschen eines Kontakts per ID.
export interface DeleteContactByIdOptions { /** * The ID of the contact to delete. * * @since 1.0.0 */ id: string;}DeleteGroupByIdOptions
Abschnitt „DeleteGroupByIdOptions“Optionen zum Löschen einer Gruppe per ID.
export interface DeleteGroupByIdOptions { /** * The ID of the group to delete. * * @since 1.0.0 */ id: string;}DisplayContactByIdOptions
Abschnitt „DisplayContactByIdOptions“Optionen zum Anzeigen eines Kontakts per ID.
export interface DisplayContactByIdOptions { /** * The ID of the contact to display. * * @since 1.0.0 */ id: string;}DisplayCreateContactOptions
Abschnitt „DisplayCreateContactOptions“Optionen zum Anzeigen der nativen UI zum Erstellen eines Kontakts.
export interface DisplayCreateContactOptions { /** * Optional pre-filled contact information for the create UI. * * @since 1.0.0 */ contact?: Omit<Contact, 'id'>;}DisplayCreateContactResult
Abschnitt mit dem Titel „DisplayCreateContactResult“Ergebnis der Anzeige des nativen UI zum Erstellen von Kontakten.
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
Abschnitt mit dem Titel „DisplayUpdateContactByIdOptions“Optionen für die Anzeige des nativen UI zum Aktualisieren von Kontakten.
export interface DisplayUpdateContactByIdOptions { /** * The ID of the contact to update. * * @since 1.0.0 */ id: string;}GetAccountsResult
Abschnitt mit dem Titel „GetAccountsResult“Ergebnis des Abrufens der Konten.
export interface GetAccountsResult { /** * List of accounts available on the device. * * @since 1.0.0 */ accounts: Account[];}Source of Truth
Abschnitt mit dem Titel „Source of Truth“Diese Seite wird aus dem Plugin- src/definitions.ts. Führe den Sync erneut aus, wenn sich der öffentliche API upstream ändert.
Weiter mit Getting Started
Abschnitt „Weiter mit Getting Started“Wenn Sie ... verwenden Erste Schritte Um Dashboard- und API-Operationen zu planen, verbinde es mit @capgo/capacitor-contacts verwenden für die native Funktionalität bei der Nutzung von @capgo/capacitor-contacts, API Übersicht für Details zur Implementierung in der Übersicht zu API, Einführung für das Implementierungsdetail in der Einleitung, API Keys für die Implementierungsdetails in den API Keys und Geräte für die Implementierungsdetails bei Devices.