Aller au contenu principal
@capgo/capacitor-rich-notifications Communication Open source

Notifications enrichies 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

Utiliser Rich Notifications dans Capacitor

Utiliser @capgo/capacitor-rich-notifications

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

Ce que ce plugin expose

  • checkPermission - Vérifier l'état de l'autorisation des notifications locales.
  • requestPermission - Demander l'autorisation des notifications locales.
  • createChannel - Créer un canal de notification Android.
  • createChannelGroup - Créer un groupe de canaux Android.
  • deleteChannel - Supprimer un canal de notification Android.
  • display - Afficher une notification locale immédiatement.
  • schedule - Planifier une notification locale pour plus tard.
  • cancel - Annuler une notification par son id.
  • cancelAll - Annuler toutes les notifications gérées par ce plugin.
  • getDisplayed - Liste des notifications affichées dans le shade ou au centre.
  • getPending - Lister les notifications planifiées non encore affichées.
  • getInitialNotification - Renvoyer la notification qui a ouvert l’application, le cas échéant.
  • setBadge - Set the app icon badge count on iOS.
  • registerActions - Enregistrer une catégorie d’actions réutilisable.
  • getPluginVersion - Renvoie le marqueur de version de l'implémentation de la plateforme.
  • addListener - Écouter les événements d’appui et de fermeture.

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 Rich Notifications

Comment installer le plugin Rich Notifications dans une application Capacitor ?

Exécutez « bun add @capgo/capacitor-rich-notifications » (ou « npm install @capgo/capacitor-rich-notifications »), puis lancez « bunx cap sync » pour que les projets iOS et Android récupèrent le code natif. Importez-le depuis « @capgo/capacitor-rich-notifications » dans votre application code.

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

Oui. Rich Notifications est un package Capacitor, il fonctionne donc avec n’importe quel framework web qui s’exécute dans Capacitor, y compris Ionic, React, Vue, Angular, Svelte et le JavaScript pur.

Quelle version de Capacitor @capgo/capacitor-rich-notifications prend-il en charge ?

Les plugins Capgo suivent la version majeure de Capacitor : utilisez la version majeure du plugin qui correspond à la version majeure de votre Capacitor (par exemple le plugin v8 avec Capacitor 8). Le tableau de compatibilité du README de GitHub recense 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 à l'adresse https://github.com/Cap-go/capacitor-rich-notifications/ et le package est gratuit à installer via npm. Les signalements de bugs et les pull requests sont les bienvenus.

Puis-je mettre à jour code utilisant les Rich Notifications sans passer par une revue de l'App Store ?

L'installation ou la mise à jour du plugin modifie le code natif, ce qui impose un nouveau build pour les stores. Ensuite, les changements JavaScript, HTML et CSS qui appellent le plugin peuvent être livrés instantanément via les live updates de Capgo.

Déployez vos modifications de Rich Notifications sans attendre la validation de l'app

Une fois le plugin intégré à votre build de store, Capgo live updates déploie vos changements JavaScript, HTML et CSS aux utilisateurs en quelques minutes.

Commencez avec Capgo