Anleitung
So nutzt du Contacts in Capacitor
Nutzung von @capgo/capacitor-contacts
Capacitor Contacts Plugin zur Verwaltung der Geräte-Kontakte.
Installieren
bun add @capgo/capacitor-contacts
bunx cap sync
bunx cap sync kopiert den nativen code des Plugins in deine nativen Projekte. Nach jedem Plugin-Upgrade erneut ausführen.
Importieren
import { CapacitorContacts } from '@capgo/capacitor-contacts';
API auf einen Blick
| Methode | Beschreibung |
|---|---|
countContacts |
Zähle die Gesamtzahl der Kontakte auf dem Gerät. |
createContact |
Erstelle einen neuen Kontakt programmatisch. |
createGroup |
Erstelle eine neue Kontaktgruppe. |
deleteContactById |
Lösche einen Kontakt per ID. |
deleteGroupById |
Lösche eine Gruppe per ID. |
displayContactById |
Zeige einen Kontakt im nativen Kontakt-Viewer an. |
displayCreateContact |
Zeigt das native UI zum Erstellen von Kontakten an. |
displayUpdateContactById |
Zeigt das native UI zum Bearbeiten eines Kontakts an. |
getAccounts |
Gibt alle auf dem Gerät verfügbaren Accounts zurück. |
getContactById |
Ruft einen spezifischen Kontakt über die ID ab. |
getContacts |
Ruft alle Kontakte vom Gerät ab. |
getGroupById |
Ruft eine spezifische Gruppe über die ID ab. |
getGroups |
Ruft alle Kontaktgruppen ab. |
isAvailable |
Prüft, ob Kontakte auf dem Gerät verfügbar sind. |
isSupported |
Prüft, ob das Plugin auf der aktuellen Plattform unterstützt wird. |
openSettings |
Öffnet die Kontakte-Einstellungen des Geräts. |
pickContact |
Wählt einen einzelnen Kontakt über den nativen Picker aus. |
pickContacts |
Wählt einen oder mehrere Kontakte über den nativen Picker aus. |
updateContactById |
Update an existing contact by ID. |
checkPermissions |
Prüfe den aktuellen Berechtigungsstatus für Kontakte. |
requestPermissions |
Berechtigungen für den Zugriff auf Kontakte anfordern. |
Beispiele
countContacts()
Zähle die Gesamtzahl der Kontakte auf dem Gerät.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.countContacts();
console.log(result);
createContact()
Erstelle einen neuen Kontakt programmatisch.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createContact({ contact: {} });
console.log(result);
createGroup()
Erstelle eine neue Kontaktgruppe.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
const result = await CapacitorContacts.createGroup({ group: { name: 'example' } });
console.log(result);
deleteContactById()
Lösche einen Kontakt per ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteContactById({ id: 'id-123' });
deleteGroupById()
Lösche eine Gruppe per ID.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.deleteGroupById({ id: 'id-123' });
displayContactById()
Zeige einen Kontakt im nativen Kontakt-Viewer an.
import { CapacitorContacts } from '@capgo/capacitor-contacts';
await CapacitorContacts.displayContactById({ id: 'id-123' });
Die obige Tabelle listet die 21 Kernmethoden auf. Listener- und Versions-Helper sowie der vollständige Contract jeder Methode sind dokumentiert in GitHub Repository.
Vollständige Referenz
Weiter mit der Nutzung von @capgo/capacitor-contacts
Wenn du es nutzt Nutzung von @capgo/capacitor-contacts um Dashboard- und API-Operationen zu planen, verbinde es mit @capgo/capacitor-contacts für die Implementierungsdetails in @capgo/capacitor-contacts, Erste Schritte für die Implementierungsdetails in Erste Schritte, API Übersicht für Details zur Implementierung im API Overview, Einführung für die Implementierungsdetails in der Einleitung und API Schlüssel für die Implementierungsdetails in den API Keys.