
Security News
Ruby's Bundler 4.0.18 Extends Cooldown to bundle lock and bundle cache
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.
@mineminemine/fcm
Advanced tools

@capacitor-community/fcm
Capacitor community plugin for enabling FCM capabilities
| Maintainer | GitHub | Social |
|---|---|---|
| Stewan Silva | stewones | @stewones |
| Daniel Pereira | danielprrazevedo | @DandanPrr |
We're starting fresh under an official org. If you were using the previous npm package capacitor-fcm, please update your package.json to @capacitor-community/fcm. Check out changelog for more info.
Using npm:
npm install @capacitor-community/fcm
Using yarn:
yarn add @capacitor-community/fcm
Sync native files:
npx cap sync
Notice
This plugin is intended to be used combined with Capacitor API for Push Notifications. Capacitor only provides APN token whereas this plugin offers the possibility to work with FCM tokens and more.
| method | info | platform |
|---|---|---|
subscribeTo | subscribe to fcm topic | ios/android |
unsubscribeFrom | unsubscribe from fcm topic | ios/android |
getToken | get fcm token to eventually use from a server | ios/android |
deleteInstance | remove local fcm instance completely | ios/android |
setAutoInit | enable the auto initialization of the library | ios/android |
isAutoInitEnabled | check whether auto initialization is enabled | ios/android |
import { FCM } from "@capacitor-community/fcm";
import { PushNotifications } from "@capacitor/push-notifications";
// external required step
// register for push
await PushNotifications.requestPermissions();
await PushNotifications.register();
// now you can subscribe to a specific topic
FCM.subscribeTo({ topic: "test" })
.then((r) => alert(`subscribed to topic`))
.catch((err) => console.log(err));
// Unsubscribe from a specific topic
FCM.unsubscribeFrom({ topic: "test" })
.then(() => alert(`unsubscribed from topic`))
.catch((err) => console.log(err));
// Get FCM token instead the APN one returned by Capacitor
FCM.getToken()
.then((r) => alert(`Token ${r.token}`))
.catch((err) => console.log(err));
// Remove FCM instance
FCM.deleteInstance()
.then(() => alert(`Token deleted`))
.catch((err) => console.log(err));
// Enable the auto initialization of the library
FCM.setAutoInit({ enabled: true }).then(() => alert(`Auto init enabled`));
// Check the auto initialization status
FCM.isAutoInitEnabled().then((r) => {
console.log("Auto init is " + (r.enabled ? "enabled" : "disabled"));
});
Navigate to the project settings page for your app on Firebase.
Download the GoogleService-Info.plist file. In Xcode right-click on the yellow folder named "App" and select the Add files to "App".
Tip: if you drag and drop your file to this location, Xcode may not be able to find it.
Download the google-services.json file and copy it to android/app/ directory of your capacitor project.
sudo gem install cocoapods (once a time)ionic start my-cap-app --capacitorcd my-cap-appmkdir www && touch www/index.htmlnpx cap add iosnpm install --save @capacitor-community/fcmnpx cap sync ios (always do sync after a plugin install)npx cap open iosGoogleService-Info.plist to the app folder in xcode// (optional) turn off `swizzling` in the `info.plist`
<key>FirebaseAppDelegateProxyEnabled</key>
<string>NO</string>
Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again.
If you need to implement opt-in behavior, you can disable the auto initialization of the library by following the Firebase docs.
ionic start my-cap-app --capacitorcd my-cap-appmkdir www && touch www/index.htmlnpx cap add androidnpm install --save @capacitor-community/fcmnpx cap sync android (always do sync after a plugin install)npx cap open androidgoogle-services.json to your android/app folder[extra step] in android case we need to tell Capacitor to initialise the plugin:Now you should be set to go. Try to run your client using ionic cap run android --livereload.
Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.
If you need to implement opt-in behavior, you can disable the auto initialization of the library by following the Firebase docs.
MIT
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Enable Firebase Cloud Messaging features for Capacitor apps
The npm package @mineminemine/fcm receives a total of 1 weekly downloads. As such, @mineminemine/fcm popularity was classified as not popular.
We found that @mineminemine/fcm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.