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-notification-expo

v1.0.0-beta.5

Published

(Non-official) Expo notification for Strapi

Downloads

5

Readme

strapi-plugin-notification-expo

npm npm GitHub package.json version GitHub issues Gitlab code coverage

(Non-official) Strapi plugins to send Expo notifications

This plugin allow you to draft & publish Expo notification

Installation

Requirements

  • Strapi >= 3.4.*
  • NodeJS >= 12.x <= 14
  • NPM >= 6.x

Install the package from your app root directory

  • With npm
npm install strapi-plugin-notification-expo
  • or yarn
yarn add strapi-plugin-notification-expo

Database information

This plugin will add 3 tables into your project :

  • expotokens : list of all Expo tokens (platform, "Expo push token", user)
  • exponotifications: list of all Notification with a state
  • exponotifications_users : list of all users than will received the notification

🚀 Features

  • Admin panel to manage notification
    • Build with Buffetjs.io
    • Used Draft and Publish Strapi feature to send notification
    • Send notification to a group of users via the Admin panel
    • Automatic publish with a dedicated cron as middleware call cronExpo
    • Set notification read-only if the notification has been sent
  • Send notification to one user programmatically (from API services/controllers)

🤖 Configuration

1. Enable cron - edit config/server.js

This project launch a Cron Task to check every 10 minutes if notification need to be send, so you need to enabled cron in config/server.js :

    cron: {
      enabled: true,
    },

If you want disable cron task on staging or development environment, edit config/env/development/server.js and disabled cron.

2. Build and re-launch Strapi

strapi build --clean
strapi dev

3. Enjoy the administration panel

  • List of all notifications (with pagination) Preview BO

  • Add / edit notification Preview BO 2

👾 Route, controllers, services

Add expo tokens

Method POST - /notification-expo/expotokens

{
  token,     // ExponentPushToken[XXXaaaBBBCCCdddEEEfff]
  platform   // 'ios' | 'android'
}

Send expo notification from an existing service to specific users

Put this code anywhere in API controllers / services

const notification = {
    user: ctx.state.user.id, // id of the user, for this example I used id of the current connected user
    title: '👍 Good job', // Notification title
    body: 'You are awesome', // Message display in the notification
    data: { 
      // additionnal data, JSON formatted, put what you need (their data are managed after into your Expo application)
      // I use often the "url" data, when use click on the notification, this is open the good screen into the app
      url: 'https://github.com/Lith/strapi-plugin-notification-expo',
    }
  };
await strapi.plugins['notification-expo'].services.expo.send(ctx, notification);

❓ FAQ

How to register expo token from your Expo App to Strapi ?

In your app, add some code to register the token linked to the user account on Strapi API :

Permissions
            .askAsync(Permissions.NOTIFICATIONS)
            .then(({status}) => {
                if (status === 'granted') {
                    return Notifications.getExpoPushTokenAsync();
                }
                return Promise.reject();
            })
            .then((token) => {
                return api
                    .post('/notification-expo/expotokens', {
                        token,
                        platform: Platform.OS
                    })
                    .catch((err) => {
                        if (err && err.statusCode === 409) {
                            return Promise.resolve();
                        } else {
                            return Promise.reject(err);
                        }
                    })
                    .then(() => dispatch(registerNotificationsTokenSuccess(
                        Notifications.addListener((notification) => {
                            dispatch(notify(notification))
                        })
                    )))
            })
            .catch((err) => dispatch(registerNotificationsTokenFail(err)))

🚧 Roadmap

  • [ ] Manage data JSON object to send additional data into the notification
  • [ ] Manage redirect URL onclick on the notification
  • [ ] Save anonymous expo token
  • [ ] Remove a draft notification
  • [ ] Duplicate an existing notification
  • [ ] Change the status of a notification (when an error occurs)
  • [ ] Schedule circle notification (sent every hour/day/week/month)
  • [ ] Add Tests with Cypress

🌟 Resources

License

Links

Support

  • Slack (Highly recommended for faster support - ping @Lith)
  • GitHub (Bug reports, contributions)