Iniziare
Copia un prompt 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.
Installare
Sezione intitolata āInstallareābun add @capgo/capacitor-firebase-messagingbunx cap syncImportare
Sezione intitolata āImportareāimport { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';Panoramica di API
Sezione intitolata āPanoramica di APIācheckPermissions
Sezione intitolata ācheckPermissionsāVerifica il permesso di ricevere notifiche push.
Attiva Su Android, questo metodo deve essere chiamato solo su Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.checkPermissions();requestPermissions
Sezione intitolata ārequestPermissionsāRichiedi il permesso di ricevere notifiche push.
Attiva Su Android, questo metodo deve essere chiamato solo su Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.requestPermissions();isSupported
Sezione intitolata āisSupportedāVerifica se esistono tutti gli API richiesti.
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 instance.
Questo metodo riabilita anche l'inizializzazione FCM automatica.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getToken();deleteToken
Sezione intitolata ādeleteTokenāCancella il token FCM e disiscrivi l'app per fermare le notifiche push. Può essere chiamato, ad esempio, quando un utente si disconnette.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteToken();getDeliveredNotifications
Sezione intitolata āgetDeliveredNotificationsāOttieni l'elenco delle notifiche visibili sulla schermata delle notifiche.
Nota: Questo restituirĆ tutte le notifiche consegnate, comprese le notifiche locali, e non solo le notifiche FCM.
Su 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 āiscriversiAlSottotemaāSi iscrive al sottotema in background.
Disponibile solo per Android e iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.subscribeToTopic({} as SubscribeToTopicOptions);unsubscribeFromTopic
Sezione intitolata ādisiscriversiDalSottotemaāSi disiscrive dal sottotema in background.
Disponibile solo per Android e iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.unsubscribeFromTopic({} as UnsubscribeFromTopicOptions);createChannel
Sezione intitolata ācreaCanaleNotificheāCrea un canale di notifiche.
Disponibile solo per Android (solo da SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({} as CreateChannelOptions);deleteChannel
Sezione intitolata āeliminaCanaleāElimina un canale di notifica.
Disponibile solo per Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({} as DeleteChannelOptions);listChannels
Sezione intitolata āelencoCanaliāElenco dei 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 āRiferimento di tipoāPermissionStatus
Sezione intitolata āStato di autorizzazioneā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 āOpzioni per l'annullamento di un argomentoāexport interface UnsubscribeFromTopicOptions { /** * The name of the topic to unsubscribe from. * * @since 0.2.2 */ topic: string;}CreateChannelOptions
Sezione intitolata āOpzioni per la creazione di un canaleāexport type CreateChannelOptions = Channel;DeleteChannelOptions
Sezione intitolata āOpzioni per la cancellazione di un canaleāexport interface DeleteChannelOptions { /** * The channel identifier. * * @since 1.4.0 */ id: string;}ListChannelsResult
Sezione intitolata āRisultati della lista dei canaliāexport interface ListChannelsResult { channels: Channel[];}TokenReceivedListener
Sezione intitolata āAscoltatore del token ricevutoā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ās src/definitions.tsRiepiloga quando le modifiche pubbliche API sono state apportate in fase di sviluppo.