Per iniziare
Copia un prompt di configurazione con i passaggi di installazione e la guida markdown completa per questo plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-rich-notifications`
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/rich-notifications/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.
Puoi usare il nostro setup assistito dall'IA per installare il plugin. Aggiungi le skill Capgo al tuo strumento di IA usando il seguente comando:
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsPoi usa il seguente prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-rich-notifications` plugin in my project.Se preferisci la configurazione manuale, installa il plugin eseguendo questi comandi e segui le istruzioni specifiche per piattaforma qui sotto:
bun add @capgo/capacitor-rich-notificationsbunx cap syncImporta
Sezione intitolata “Import”import { RichNotifications } from '@capgo/capacitor-rich-notifications';Avvio rapido
Sezione intitolata “Quick start”import { RichNotifications } from '@capgo/capacitor-rich-notifications';
const { status } = await RichNotifications.requestPermission();if (status !== 'granted') return;Esempio: createChannel
Sezione intitolata “Esempio: createChannel”import { RichNotifications } from '@capgo/capacitor-rich-notifications';
await RichNotifications.createChannel({ id: 'alerts', name: 'Alerts', importance: 'high',});Esempio: display
Sezione intitolata “Esempio: display”import { RichNotifications } from '@capgo/capacitor-rich-notifications';
const { id } = await RichNotifications.display({ title: 'Hello', body: 'Tap to open', channelId: 'alerts',});Errori comuni
Sezione intitolata “Errori comuni”- Listener: rimuovi gli handle quando gli schermi vengono smontati.
- Sync nativo: esegui
bunx cap syncdopo gli aggiornamenti dei plugin. - Fonte di verità: fidati
src/definitions.tsnel repo GitHub.
Configurazione della piattaforma
Sezione intitolata “Configurazione della piattaforma”- Setup iOS per categorie e livelli di interruzione.
- Configurazione Android per
POST_NOTIFICATIONS, canali e facoltative autorizzazioni per allarmi esatti o servizi in primo piano.
Utilizzo
Sezione intitolata “Usage”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);});