itisnajim / strapi-plugin-fcm

Send FCM notifications from your Strapi app.
MIT License
22 stars 11 forks source link
fcm fcm-notifications firebase-cloud-messaging notifications strapi strapi-plugin strapi-plugin-fcm strapi-v4

Strapi v4 - FCM plugin

Send FCM notifications from Strapi.

NPM Version Monthly download on NPM codecov.io


Installation

From NPM:

npm install strapi-plugin-fcm

From YARN:

yarn add strapi-plugin-fcm

From Git:

  1. Clone the plugin into your Strapi project
cd /<path-to-your-strapi-project>/src

# create plugins folder if not exists
# mkdir plugins

# go to plugins folder
cd plugins

# clone the plugin code into a folder and skip the prefix
git clone https://github.com/itisnajim/strapi-plugin-fcm.git strapi-plugin-fcm
# install dependencies
cd strapi-plugin-fcm && yarn install # or npm install
  1. Enable the plugin in <root>/config/plugins.js .
module.exports = {
  // ...
  'strapi-plugin-fcm': {
    enabled: true,
    resolve: './src/plugins/strapi-plugin-fcm' // path to plugin folder
  },
  // ...
}
  1. Build the plugin
# back to project root and build the plugin
yarn build # or npm run build
# start
yarn develop # or npm run develop

Configuration

Usage

Via the dashboard

Another way via the dashboard.

Via the api

{
    "data": {
        "title": "OKey",
        "body": "Test body",
        "image": "",
        "payload": "",
        "targetType": "topics",
        //or "targetType": "tokens",
        "target": "client_android",
        //or multiple topics "target": "client_android,client_ios",
        //or "target": "eyJhbGciOiJFUzI1...",
        //publishedAt: null //<<- uncomment this if you want to just add an entry as a draft to 'FCM Notification' collection without publishing and sending FCM.
    }
}

Trick

If you have saved the entries in the FCM Notification collection as drafts, you can scheduled them to be sent to FCM at a later time.


References