Aller directement au contenu principal
@capgo/capacitor-notifications riches La communication Source ouvert

Notifications riches plugin Capacitor

Notifications locales avec canaux Android, layouts de progression, boutons d'action, planification et niveaux d'interruption iOS

Installer

bun add @capgo/capacitor-rich-notifications bunx cap sync
npm, pnpm ou yarn
  • npm install @capgo/capacitor-rich-notifications
  • pnpm add @capgo/capacitor-rich-notifications
  • yarn add @capgo/capacitor-rich-notifications

Guide

Comment utiliser les notifications riches dans Capacitor

Utilisation de @capgo/capacitor-rich-notifications

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.
  • createChannelGroup Créez un groupe de canaux 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.
  • getPluginVersion Renvoie 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 },
});

Référence complète

FAQ

FAQ du plugin de notifications riches

Comment installer le plugin de notifications riches dans une application Capacitor ?

Exécutez la commande « bun add @capgo/capacitor-rich-notifications » (ou « npm install @capgo/capacitor-rich-notifications »), puis exécutez « bunx cap sync » afin que les projets iOS et Android prennent en compte les code natives. Importez-l’à partir de « @capgo/capacitor-rich-notifications » dans votre application code.

Le plugin @capgo/capacitor-rich-notifications fonctionne-t-il avec React, Vue et Angular ?

Oui. Le plugin de notifications riches est un package Capacitor, il fonctionne donc avec tout framework web qui s'exécute à l'intérieur de Capacitor, y compris Ionic, React, Vue, Angular, Svelte et JavaScript pur.

Quelle version de Capacitor est prise en charge par @capgo/capacitor-rich-notifications ?

Capgo plugins suivent la version majeure de Capacitor : utilisez la version majeure du plugin qui correspond à la version majeure de votre Capacitor (par exemple, plugin v8 avec Capacitor 8). La table de compatibilité dans le README du GitHub liste les versions maintenues.

Est-ce que @capgo/capacitor-rich-notifications est gratuit et open source ?

Oui. Le code source de code est public sur GitHub à https://github.com/Cap-go/capacitor-rich-notifications/ et le package est gratuit pour l'installer depuis npm. Les rapports de bugs et les demandes de mise à jour sont les bienvenus.

Puis-je mettre à jour code qui utilise les notifications riches sans passer par une revue de l'App Store ?

L'installation ou la mise à jour du plugin modifie la code native, elle nécessite donc une nouvelle construction de l'application. Une fois cela fait, les modifications JavaScript, HTML et CSS qui appellent le plugin peuvent être déployées instantanément avec les mises à jour Capgo.

Envoyez les modifications des notifications riches sans attendre la revue de l'application

Une fois le plugin est dans votre magasin de build, les mises à jour Capgo en direct poussent vos modifications JavaScript, HTML et CSS vers les utilisateurs en quelques minutes.

Démarrez avec Capgo