Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this 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.
Install
Section titled āInstallābun add @capgo/capacitor-firebase-messagingbunx cap syncimport { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';API Overview
Section titled āAPI OverviewācheckPermissions
Section titled ācheckPermissionsāCheck permission to receive push notifications.
On Android, this method only needs to be called on Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.checkPermissions();requestPermissions
Section titled ārequestPermissionsāRequest permission to receive push notifications.
On Android, this method only needs to be called on Android 13+.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.requestPermissions();isSupported
Section titled āisSupportedāChecks if all required APIs exist.
Always returns true on Android and iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.isSupported();getToken
Section titled āgetTokenāRegister the app to receive push notifications. Returns a FCM token that can be used to send push messages to that Messaging instance.
This method also re-enables FCM auto-init.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getToken();deleteToken
Section titled ādeleteTokenāDelete the FCM token and unregister the app to stop receiving push notifications. Can be called, for example, when a user signs out.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteToken();getDeliveredNotifications
Section titled āgetDeliveredNotificationsāGet a list of notifications that are visible on the notifications screen.
Note: This will return all delivered notifications, including local notifications, and not just FCM notifications.
On Android, the data field of the FCM notification will NOT be included.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.getDeliveredNotifications();removeDeliveredNotifications
Section titled āremoveDeliveredNotificationsāRemove specific notifications from the notifications screen.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeDeliveredNotifications({} as RemoveDeliveredNotificationsOptions);removeAllDeliveredNotifications
Section titled āremoveAllDeliveredNotificationsāRemove all notifications from the notifications screen.
Note: This will remove all delivered notifications, including local notifications, and not just FCM notifications.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.removeAllDeliveredNotifications();subscribeToTopic
Section titled āsubscribeToTopicāSubscribes to topic in the background.
Only available for Android and iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.subscribeToTopic({} as SubscribeToTopicOptions);unsubscribeFromTopic
Section titled āunsubscribeFromTopicāUnsubscribes from topic in the background.
Only available for Android and iOS.
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.unsubscribeFromTopic({} as UnsubscribeFromTopicOptions);createChannel
Section titled ācreateChannelāCreate a notification channel.
Only available for Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.createChannel({} as CreateChannelOptions);deleteChannel
Section titled ādeleteChannelāDelete a notification channel.
Only available for Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.deleteChannel({} as DeleteChannelOptions);listChannels
Section titled ālistChannelsāList the available notification channels.
Only available for Android (SDK 26+).
import { FirebaseMessaging } from '@capgo/capacitor-firebase-messaging';
await FirebaseMessaging.listChannels();Type Reference
Section titled āType ReferenceāPermissionStatus
Section titled āPermissionStatusāexport interface PermissionStatus { /** * @since 0.2.2 */ receive: PermissionState;}IsSupportedResult
Section titled āIsSupportedResultāexport interface IsSupportedResult { /** * @since 0.3.1 */ isSupported: boolean;}GetTokenOptions
Section titled ā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 titled āGetTokenResultāexport interface GetTokenResult { /** * @since 0.2.2 */ token: string;}GetDeliveredNotificationsResult
Section titled āGetDeliveredNotificationsResultāexport interface GetDeliveredNotificationsResult { /** * @since 0.2.2 */ notifications: Notification[];}RemoveDeliveredNotificationsOptions
Section titled āRemoveDeliveredNotificationsOptionsāexport interface RemoveDeliveredNotificationsOptions { /** * @since 0.4.0 */ notifications: Notification[];}SubscribeToTopicOptions
Section titled āSubscribeToTopicOptionsāexport interface SubscribeToTopicOptions { /** * The name of the topic to subscribe. * * @since 0.2.2 */ topic: string;}UnsubscribeFromTopicOptions
Section titled āUnsubscribeFromTopicOptionsāexport interface UnsubscribeFromTopicOptions { /** * The name of the topic to unsubscribe from. * * @since 0.2.2 */ topic: string;}CreateChannelOptions
Section titled āCreateChannelOptionsāexport type CreateChannelOptions = Channel;DeleteChannelOptions
Section titled āDeleteChannelOptionsāexport interface DeleteChannelOptions { /** * The channel identifier. * * @since 1.4.0 */ id: string;}ListChannelsResult
Section titled āListChannelsResultāexport interface ListChannelsResult { channels: Channel[];}TokenReceivedListener
Section titled āTokenReceivedListenerāCallback to receive the token received event.
export type TokenReceivedListener = (event: TokenReceivedEvent) => void;Source Of Truth
Section titled āSource Of TruthāThis page is generated from the pluginās src/definitions.ts. Re-run the sync when the public API changes upstream.