Iniziare
Copia un promemoria 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-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.
bun add @capgo/capacitor-firebase-messagingbunx cap syncimport { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';API Panoramica
Sezione intitolata âAPI PanoramicaâcheckPermissions
Sezione intitolata âcheckPermissionsâVerifica le autorizzazioni per ricevere le notifiche push.
Attivo Android, questo metodo deve essere chiamato solo su Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.checkPermissions();requestPermissions
Sezione intitolata ârichiesta di permessiâRichiedi il permesso di ricevere notifiche push.
Sempre Android, questo metodo deve essere chiamato solo su Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.requestPermissions();isSupported
Sezione intitolata âè supportatoâVerifica se esistono tutte le API richieste.
Restituisce sempre true su Android e iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.isSupported();Registra l'app per ricevere notifiche push. Restituisce un token FCM che può essere utilizzato per inviare messaggi push a quel Messaging istanza.
Questa funzione riabilita anche l'inizializzazione FCM automatica.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getToken();deleteToken
Sezione intitolata âdeleteTokenâElimina il token FCM e disiscrivi l'app per fermare di ricevere notifiche push. Può essere chiamata, ad esempio, quando un utente si disconnette.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteToken();getDeliveredNotifications
Sezione intitolata âgetDeliveredNotificationsâOttieni una lista di notifiche che sono visibili sulla schermata delle notifiche.
Nota: Questo restituirĂ tutte le notifiche consegnate, comprese le notifiche locali, e non solo le notifiche FCM.
Sul dispositivo Android, il campo dati della notifica FCM NON sarĂ incluso.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getDeliveredNotifications();removeDeliveredNotifications
Sezione intitolata âremoveDeliveredNotificationsâElimina specifiche notifiche dalla schermata delle notifiche.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeDeliveredNotifications({} as RemoveDeliveredNotificationsOptions);removeAllDeliveredNotifications
Sezione intitolata âremoveAllDeliveredNotificationsâElimina tutte le notifiche dalla schermata delle notifiche.
Nota: Questo eliminerĂ tutte le notifiche consegnate, comprese le notifiche locali, e non solo le notifiche FCM.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeAllDeliveredNotifications();subscribeToTopic
Sezione intitolata âsubscribeToTopicâSi sottoscrive al tema in background.
Disponibile solo per Android e iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.subscribeToTopic({} as SubscribeToTopicOptions);unsubscribeFromTopic
Sezione intitolata âdisiscriversiDaArgomentoâSi disiscrive dall'argomento in background.
Disponibile solo per Android e iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.unsubscribeFromTopic({} as UnsubscribeFromTopicOptions);createChannel
Sezione intitolata âcreaCanaleâCrea un canale di notifica.
Only available for Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({} as CreateChannelOptions);deleteChannel
Sezione intitolata âeliminaCanaleâElimina un canale di notifica.
Only available for Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({} as DeleteChannelOptions);listChannels
Sezione intitolata âlistChannelsâElencare i canali di notifica disponibili.
Disponibile solo per Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.listChannels();Riferimento di tipo
Sezione intitolata âType ReferenceâPermissionStatus
Sezione intitolata âPermissionStatusâexport interface PermissionStatus { /** * @since 0.2.2 */ receive: PermissionState;}IsSupportedResult
Sezione intitolata âIsSupportedResultâexport interface IsSupportedResult { /** * @since 0.3.1 */ isSupported: boolean;}GetTokenOptions
Sezione intitolata â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
Sezione intitolata âGetTokenResultâexport interface GetTokenResult { /** * @since 0.2.2 */ token: string;}GetDeliveredNotificationsResult
Sezione intitolata âGetDeliveredNotificationsResultâexport interface GetDeliveredNotificationsResult { /** * @since 0.2.2 */ notifications: Notification[];}RemoveDeliveredNotificationsOptions
Sezione intitolata âRemoveDeliveredNotificationsOptionsâexport interface RemoveDeliveredNotificationsOptions { /** * @since 0.4.0 */ notifications: Notification[];}SubscribeToTopicOptions
Sezione intitolata âSubscribeToTopicOptionsâexport interface SubscribeToTopicOptions { /** * The name of the topic to subscribe. * * @since 0.2.2 */ topic: string;}UnsubscribeFromTopicOptions
Sezione intitolata âUnsubscribeFromTopicOptionsâexport interface UnsubscribeFromTopicOptions { /** * The name of the topic to unsubscribe from. * * @since 0.2.2 */ topic: string;}CreateChannelOptions
Sezione intitolata âCreateChannelOptionsâexport type CreateChannelOptions = Channel;DeleteChannelOptions
Sezione intitolata âDeleteChannelOptionsâexport interface DeleteChannelOptions { /** * The channel identifier. * * @since 1.4.0 */ id: string;}ListChannelsResult
Sezione intitolata âListChannelsResultâexport interface ListChannelsResult { channels: Channel[];}TokenReceivedListener
Sezione intitolata âTokenReceivedListenerâCallback per ricevere l'evento del token ricevuto.
export type TokenReceivedListener = (event: TokenReceivedEvent) => void;Fonte di VeritĂ
Sezione intitolata âFonte di VeritĂ âQuesta pagina è generata dal plugin. src/definitions.tsRiesegui la sincronizzazione quando i dati pubblici API cambiano upstream.
Continua da Getting Started
Sottosezione intitolata âContinua da Getting StartedâSe stai utilizzando Getting Started per pianificare il dashboard e le operazioni di API API Overview API Overview per i dettagli di implementazione in __CAPGO_KEEP_0__ Overview Introduzione API Keys API Keys per i dettagli di implementazione in __CAPGO_KEEP_0__ Keys per i dettagli di implementazione in Devices, e Bundles per i dettagli di implementazione in Bundles.