Saltare al contenuto

Iniziare

Finestra del terminale
bun add @capgo/capacitor-firebase-messaging
bunx cap sync
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';

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();

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();

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();

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();

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();

Elimina specifiche notifiche dalla schermata delle notifiche.

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeDeliveredNotifications({} as RemoveDeliveredNotificationsOptions);

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();

Si iscrive al sottotema in background.

Disponibile solo per Android e iOS.

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.subscribeToTopic({} as SubscribeToTopicOptions);

Si disiscrive dal sottotema in background.

Disponibile solo per Android e iOS.

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.unsubscribeFromTopic({} as UnsubscribeFromTopicOptions);

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);

Elimina un canale di notifica.

Disponibile solo per Android (SDK 26+).

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({} as DeleteChannelOptions);

Elenco dei canali di notifica disponibili.

Disponibile solo per Android (SDK 26+).

import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.listChannels();
export interface PermissionStatus {
/**
* @since 0.2.2
*/
receive: PermissionState;
}
export interface IsSupportedResult {
/**
* @since 0.3.1
*/
isSupported: boolean;
}
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;
}
export interface GetTokenResult {
/**
* @since 0.2.2
*/
token: string;
}
export interface GetDeliveredNotificationsResult {
/**
* @since 0.2.2
*/
notifications: Notification[];
}
export interface RemoveDeliveredNotificationsOptions {
/**
* @since 0.4.0
*/
notifications: Notification[];
}
export interface SubscribeToTopicOptions {
/**
* The name of the topic to subscribe.
*
* @since 0.2.2
*/
topic: string;
}
export interface UnsubscribeFromTopicOptions {
/**
* The name of the topic to unsubscribe from.
*
* @since 0.2.2
*/
topic: string;
}
export type CreateChannelOptions = Channel;
export interface DeleteChannelOptions {
/**
* The channel identifier.
*
* @since 1.4.0
*/
id: string;
}
export interface ListChannelsResult {
channels: Channel[];
}

Callback per ricevere l'evento del token ricevuto.

export type TokenReceivedListener = (event: TokenReceivedEvent) => void;

Questa pagina ĆØ generata dal plugin’s src/definitions.tsRiepiloga quando le modifiche pubbliche API sono state apportate in fase di sviluppo.