capacitor-community / Fcm

Licence: mit
Enable Firebase Cloud Messaging for Capacitor apps

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Fcm

Ionic Firebase Chat
Create a Real Time Chat App with Ionic && Firebase
Stars: ✭ 33 (-72.5%)
Mutual labels:  firebase, ionic
Pwa Workshop Angular Firebase
Build a production ready PWA with Angular and Firebase! This workshop consists of multiple steps for producing a PWA by transforming a regular web app - Ionic Conference App into a PWA, finally deploying it to Firebase.
Stars: ✭ 45 (-62.5%)
Mutual labels:  firebase, ionic
Push Fcm Plugin
Official Firebase Cloud Messaging plugin for Push.js v1.0 🔥
Stars: ✭ 37 (-69.17%)
Mutual labels:  firebase, fcm
Awesome Firebase
🔥 List of Firebase talks, tools, examples & articles! Translations in 🇬🇧 🇷🇺 Contributions welcome!
Stars: ✭ 448 (+273.33%)
Mutual labels:  firebase, fcm
Ionic Firebase Starter App
Ionic 4 firebase CRUD tutorial to learn how to create a firebase application to perform Authentication and all CRUD operations in an ionic 4 application. You can use this FREE Ionic Firebase Starter App as a base to create your Ionic App with Firebase backend :)
Stars: ✭ 77 (-35.83%)
Mutual labels:  firebase, ionic
Pyfcm
Python client for FCM - Firebase Cloud Messaging (Android, iOS and Web)
Stars: ✭ 674 (+461.67%)
Mutual labels:  firebase, fcm
Kotlin Firebase Group Chat
Group and OneonOne chat using firebase built in Kotlin similar to whatsapp.
Stars: ✭ 44 (-63.33%)
Mutual labels:  firebase, fcm
Go Fcm
Firebase Cloud Messaging ( FCM ) Library using golang ( Go )
Stars: ✭ 212 (+76.67%)
Mutual labels:  firebase, fcm
Pushraven
A simple Java library to interface with Firebase Cloud Messaging (FCM) API. Pushraven allows you to push notifications to clients in very few lines of code.
Stars: ✭ 67 (-44.17%)
Mutual labels:  firebase, fcm
Ionic Social Login With Firebase
IONIC - Social Login with Firebase
Stars: ✭ 58 (-51.67%)
Mutual labels:  firebase, ionic
OneSignal-Ionic-Sample
No description or website provided.
Stars: ✭ 85 (-29.17%)
Mutual labels:  ionic, fcm
React Native Firebase
🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
Stars: ✭ 9,674 (+7961.67%)
Mutual labels:  firebase, fcm
Ionic Firebase Shopping Cart
HTML5 shopping cart using Firebase
Stars: ✭ 236 (+96.67%)
Mutual labels:  firebase, ionic
Espionage
An android application that can be run in background and give commands from fcm console to share sensor data
Stars: ✭ 18 (-85%)
Mutual labels:  firebase, fcm
Fcm Toolbox
📲 Firebase Cloud Messaging toolbox
Stars: ✭ 217 (+80.83%)
Mutual labels:  firebase, fcm
Nativescript Plugin Firebase
🔥 NativeScript plugin for Firebase
Stars: ✭ 990 (+725%)
Mutual labels:  firebase, fcm
React Native Fcm
react native module for firebase cloud messaging and local notification
Stars: ✭ 1,729 (+1340.83%)
Mutual labels:  firebase, fcm
Fcm
Firebase Cloud Messaging (FCM) notifications channel for Laravel
Stars: ✭ 169 (+40.83%)
Mutual labels:  firebase, fcm
Ionic Chat With Firebase
IONIC Chat With Firebase
Stars: ✭ 53 (-55.83%)
Mutual labels:  firebase, ionic
Ionic Firebase Mega Starter
Mega Starter template for Ionic & Firebase Apps
Stars: ✭ 78 (-35%)
Mutual labels:  firebase, ionic


Capacitor FCM

@capacitor-community/fcm

Capacitor community plugin for enabling FCM capabilities


Maintainers

Maintainer GitHub Social
Stewan Silva stewones @stewones
Daniel Pereira danielprrazevedo @DandanPrr

Notice 🚀

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.

Installation

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.

API

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

Usage

import { Plugins } from '@capacitor/core';
const { PushNotifications } = Plugins;

//
// with type support
import { FCM } from '@capacitor-community/fcm';
const fcm = new FCM();

//
// alternatively - without types
const { FCMPlugin } = Plugins;

//
// external required step
// register for push
PushNotifications.register()
  .then(() => {
    //
    // Subscribe to a specific topic
    // you can use `FCMPlugin` or just `fcm`
    fcm
      .subscribeTo({ topic: 'test' })
      .then((r) => alert(`subscribed to topic`))
      .catch((err) => console.log(err));
  })
  .catch((err) => alert(JSON.stringify(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'));
});

Add Google config files

Navigate to the project settings page for your app on Firebase.

iOS

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.

Android

Download the google-services.json file and copy it to android/app/ directory of your capacitor project.

Certificate

iOS setup

  • sudo gem install cocoapods (once a time)
  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • mkdir www && touch www/index.html
  • npx cap add ios
  • npm install --save @capacitor-community/fcm
  • npx cap sync ios (always do sync after a plugin install)
  • npx cap open ios
  • sign your app at xcode (general tab)
  • enable remote notification capabilities
  • add GoogleService-Info.plist to the app folder in xcode
// (optional) turn off `swizzling` in the `info.plist`
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>

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.

Prevent auto initialization

If you need to implement opt-in behavior, you can disable the auto initialization of the library by following the Firebase docs.

Android setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • mkdir www && touch www/index.html
  • npx cap add android
  • npm install --save @capacitor-community/fcm
  • npx cap sync android (always do sync after a plugin install)
  • npx cap open android
  • add google-services.json to your android/app folder
  • [extra step] in android case we need to tell Capacitor to initialise the plugin:

on your MainActivity.java file add import com.getcapacitor.community.fcm.FCMPlugin; and then inside the init callback add(FCMPlugin.class);

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.

Prevent auto initialization

If you need to implement opt-in behavior, you can disable the auto initialization of the library by following the Firebase docs.

Example

License

MIT

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Stew

💻 📖

Daniel Pereira

💻 📖

Priyank Patel

💻

Nikolas

🚧

Ben Schattinger

💻

James Manners

💻

Borja Rodríguez

🚧

Karrlllis

📖

jamesmah

💻

Josh Sharpe

🚧

Mantas Šimkūnas

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].