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

@indoomni/strapi-plugin-firebase-admin

v1.0.6

Published

Wrapper for Firebase Admin Node.js SDK library to be used with Strapi apps.

Downloads

8

Readme

🚀 Getting started with Strapi

Wrapper for google-wombot's Firebase Admin Node.js SDK library to be used with Strapi apps. You are going to need a Google Firebase service account credential file (for more information, head on to https://firebase.google.com/). The Strapi app will be able to send push notification to clients reporting their FCM token, do analytics and stuff. Note: As of the time of writing this document, only the push notification has been implemented. Save the FCM token of each client on login, register, or some other onboarding scheme you may have setup.

Installation

Add the library to your Strapi project. Learn more


yarn add @indoomni/strapi-plugin-firebase-admin
yarn install
yarn build

Configuration

Add the following configuration attributes to your server.js.


# config/server.js or config/env/**/server.js
# -------------------------------------------

module.exports = ({ env }) => ({
  host: env('HOST'),
  port: env.int('PORT'),
  app: {
    env: env('ENV'),
    name: env('APP_NAME'),
    keys: env.array('APP_KEYS'),
  },
  // ...
  'firebase-admin': {
    enabled: true,
    config: {
      configFile: '../service-account.json',
      clientId: `${env('APP_NAME')}_${env('ENV')}_fcm`,
      services: ['notification'],
      tags: [],
      test: {
        token: 'xyz123',
        title: 'Hello!',
        body: 'Hello world!',
      },
    },
  },
  // ...
});

Notice config sub-attribute in the the 'firebase-admin' attribute. Don't forget to use the single-quotation marks.

Now, notice the configFile attribute. Your service account JSON file should reside on the root of your project (add "../" since we use "src" for the base directory). The other attributes are currently ignored and supplied for future development. If you supply a test attribute, the library will try to send a message to the said token after initialized.

How to send messages

Anywhere in your code, write as in the following snippet. Refer to the admin controller inside the library, and call send function. Supply a client's FCM token, title, body and data if necessary. Note: If you specify [data], it will be encrypted as Base64 string. At your client app's side, when you receive the notification, decode the data using some Base64 encryption, then use the data as needed.


# src/**/any.js
# ------------------------------

// ...
try {
  await strapi
    .plugin('firebase-admin')
    .controller('admin')
    .send(token, title, body, data);
} catch (err) {
  strapi.log.debug('📺: ', err);
}
// ...

📚 Learn more


Feel free to check out my GitHub repository. Your feedback and contributions are welcome!