Zum Inhalt springen

Erste Schritte

GitHub

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:

Terminalfenster
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Nutze anschließend diesen Prompt:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-rich-notifications` plugin in my project.

Wenn du ein manuelles Setup bevorziehst, installiere das Plugin mit den folgenden Befehlen und befolge die plattformspezifischen Anweisungen unten:

Terminalfenster
bun add @capgo/capacitor-rich-notifications
bunx cap sync
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
const { status } = await RichNotifications.requestPermission();
if (status !== 'granted') return;
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
await RichNotifications.createChannel({
id: 'alerts',
name: 'Alerts',
importance: 'high',
});
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
const { id } = await RichNotifications.display({
title: 'Hello',
body: 'Tap to open',
channelId: 'alerts',
});
  • Listener: Handles entfernen, wenn Screens unmounten.
  • Native Sync: ausführen bunx cap sync nach Plugin-Upgrades.
  • Single Source of Truth: vertraue src/definitions.ts im GitHub Repo.
  • iOS-Setup für Kategorien und Unterbrechungsstufen.
  • Android-Setup für POST_NOTIFICATIONS, Channels sowie optionale Berechtigungen für exakte Alarme oder Foreground Services.
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
await RichNotifications.requestPermission();
await RichNotifications.createChannel({
id: 'messages',
name: 'Messages',
importance: 'high',
});
await RichNotifications.display({
title: 'Hello',
body: 'Tap to open the app',
channelId: 'messages',
});
await RichNotifications.addListener('press', (event) => {
console.log(event.id, event.actionId, event.input);
});