Guide
Comment utiliser les notifications riches dans Capacitor
Utilisation de @capgo/capacitor-notifications-riches
Notifications locales avec canaux Android, dispositions de progression, boutons d'action, planification et niveaux d'interruption iOS.
Installer
bun add @capgo/capacitor-rich-notifications
bunx cap sync
Ceci que ce plugin expose
checkPermission- Vérifiez l'état de la permission de notification locale.requestPermission- Demandez la permission de notification locale.createChannel- Créez un canal de notification Android.createChannelGroupCréez un groupe de chaînes Android.deleteChannel- Supprimez un canal de notification Android.display- Affichez une notification locale immédiatement.schedule- Planifiez une notification locale pour plus tard.cancel- Annulez une notification par son ID.cancelAll- Annulez toutes les notifications gérées par ce plugin.getDisplayed- Liste des notifications affichées dans l'ombre ou au centre.getPending- Liste des notifications programmées non encore affichées.getInitialNotification- Renvoyez la notification qui a ouvert l'application, si elle existe.setBadge- Set the app icon badge count on iOS.registerActions- Enregistrez une catégorie d'action réutilisable.getPluginVersionRenvoie le marqueur de version de l'implémentation de la plateforme.addListener- Écoutez les événements de pression et de suppression.
- Exemple d'utilisation
requestPermission - Et display
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',
});
schedule
import { RichNotifications } from '@capgo/capacitor-rich-notifications';
await RichNotifications.schedule({
notification: {
id: 'reminder-1',
title: 'Reminder',
body: 'Your appointment starts soon',
channelId: 'messages',
},
trigger: { type: 'timestamp', timestamp: Date.now() + 60_000 },
});
- Documentation complète
- - GitHub: https://github.com/Cap-go/capacitor-notifications-riche/
- - Documentation : /docs/plugins/notifications-riche/