npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

strapi-plugin-fcm

v1.1.0

Published

Send notifications to users or topics using The Google's service: Firebase Cloud Messaging.

Downloads

255

Readme

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

  • In the Firebase console, open Settings > Service Accounts.
  • Click Generate New Private Key, then confirm by clicking Generate Key.
  • Past the content of your downloaded service account json file into FCM Plugin Configuration > serviceAccount. (like in the picture below, then you may need to restart the server)
  • In the same interface 'FCM Plugin Configuration', optionally you can provide where the devices tokens are stored, in the picture example above, I store them in User -> deviceToken (strapi generate the users database table with the name up_users).

  • Optionally you can provide all the topics you have, in the 'FCM Topic' collection type (via the dashboard or via the api - Post requests).

Usage

Via the dashboard

  • Enter the notification content.
  • Select targets to send to.
  • Click send!

Another way via the dashboard.

  • you can create a new entry in the 'FCM Notification' collection type and click publish to send to the FCM.

Via the api

  • First you have to enable and give routes permissions to a specific role or roles.
{
    "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.
    }
}
  • You can send an array too:
{
    "data": [{...entry1}, {...entry2}, {...entry3}, ...]
}

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