Démarrage
Copiez un prompt de configuration avec les étapes d'installation et le guide Markdown complet pour ce plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-firebase-messaging`
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/firebase-messaging/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.
Installer
Sous-section intitulée « Installer »bun add @capgo/capacitor-firebase-messagingbunx cap syncimport { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';API Vue d'ensemble
Sous-section intitulée « API Vue d'ensemble »checkPermissions
Section intitulée « checkPermissions »Vérifiez les permissions pour recevoir les notifications push.
Sur Android, cette méthode n'a besoin d'être appelée que sur Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.checkPermissions();requestPermissions
Section intitulée « requestPermissions »Demandez les permissions pour recevoir les notifications push.
Sur Android, cette méthode n'a besoin d'être appelée que sur Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.requestPermissions();isSupported
Section intitulée « isSupported »Vérifie si tous les API requis existent.
Renvoie toujours true sur Android et iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.isSupported();getToken
Section intitulée « getToken »Inscrivez l'application pour recevoir les notifications push. Renvoie un jeton FCM pouvant être utilisé pour envoyer des messages push à cette instance de Messaging.
Cette méthode réactive également l'auto-init FCM.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getToken();deleteToken
Section intitulée « deleteToken »Supprime le jeton FCM et désinscrit l'application pour arrêter de recevoir les notifications push. Peut être appelée, par exemple, lorsqu'un utilisateur se déconnecte.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteToken();getDeliveredNotifications
Section intitulée “getDeliveredNotifications”Obtenez une liste de notifications visibles sur l’écran des notifications.
Remarque : Cette méthode retournera toutes les notifications livrées, y compris les notifications locales, et non seulement les notifications FCM.
Sur Android, le champ de données de la notification FCM NE sera PAS inclus.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getDeliveredNotifications();removeDeliveredNotifications
Section intitulée “removeDeliveredNotifications”Supprimer des notifications spécifiques de l’écran des notifications.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeDeliveredNotifications({} as RemoveDeliveredNotificationsOptions);removeAllDeliveredNotifications
Section intitulée “removeAllDeliveredNotifications”Supprimer toutes les notifications de l’écran des notifications.
Remarque : Cette méthode supprimera toutes les notifications livrées, y compris les notifications locales, et non seulement les notifications FCM.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeAllDeliveredNotifications();subscribeToTopic
Section intitulée “souscrireAuSujet”Souscrit au sujet en arrière-plan.
Disponible uniquement pour Android et iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.subscribeToTopic({} as SubscribeToTopicOptions);unsubscribeFromTopic
Section intitulée “seDésinscrireDuSujet”Se désinscrit du sujet en arrière-plan.
Disponible uniquement pour Android et iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.unsubscribeFromTopic({} as UnsubscribeFromTopicOptions);createChannel
Section intitulée “créerChaîneDeNotification”Crée une chaîne de notification.
Disponible uniquement pour Android (seulement à partir de SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({} as CreateChannelOptions);deleteChannel
Section intitulée “deleteChannel”Supprimer un canal de notification.
Disponible uniquement pour Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({} as DeleteChannelOptions);listChannels
Section intitulée “listChannels”Lister les canaux de notification disponibles.
Disponible uniquement pour Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.listChannels();Référence de type
Section intitulée “Type Reference”PermissionStatus
Section intitulée “PermissionStatus”export interface PermissionStatus { /** * @since 0.2.2 */ receive: PermissionState;}IsSupportedResult
Section intitulée « IsSupportedResult »export interface IsSupportedResult { /** * @since 0.3.1 */ isSupported: boolean;}GetTokenOptions
Section intitulée « GetTokenOptions »export interface GetTokenOptions { /** * Your VAPID public key, which is required to retrieve the current registration token on the web. * * Only available for Web. */ vapidKey?: string; /** * The service worker registration for receiving push messaging. * If the registration is not provided explicitly, you need to have a `firebase-messaging-sw.js` at your root location. * * Only available for Web. */ serviceWorkerRegistration?: ServiceWorkerRegistration;}GetTokenResult
Section intitulée « GetTokenResult »export interface GetTokenResult { /** * @since 0.2.2 */ token: string;}GetDeliveredNotificationsResult
Section intitulée « GetDeliveredNotificationsResult »export interface GetDeliveredNotificationsResult { /** * @since 0.2.2 */ notifications: Notification[];}RemoveDeliveredNotificationsOptions
Section intitulée « RemoveDeliveredNotificationsOptions »export interface RemoveDeliveredNotificationsOptions { /** * @since 0.4.0 */ notifications: Notification[];}SubscribeToTopicOptions
Section intitulée « SubscribeToTopicOptions »export interface SubscribeToTopicOptions { /** * The name of the topic to subscribe. * * @since 0.2.2 */ topic: string;}UnsubscribeFromTopicOptions
Section intitulée « Options de désabonnement d'un sujet »export interface UnsubscribeFromTopicOptions { /** * The name of the topic to unsubscribe from. * * @since 0.2.2 */ topic: string;}CreateChannelOptions
Section intitulée « Options de création d'un canal »export type CreateChannelOptions = Channel;DeleteChannelOptions
Section intitulée « Options de suppression d'un canal »export interface DeleteChannelOptions { /** * The channel identifier. * * @since 1.4.0 */ id: string;}ListChannelsResult
Section intitulée « Résultats de la liste des canaux »export interface ListChannelsResult { channels: Channel[];}TokenReceivedListener
Section intitulée « Écouteur de réception du jeton »Appel de rappel pour recevoir l'événement de réception du jeton.
export type TokenReceivedListener = (event: TokenReceivedEvent) => void;Source de vérité
Section intitulée « Source De Vérité »Cette page est générée à partir du plugin’s src/definitions.tsRe-faites la synchronisation lorsque le public API change en amont.