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

pushalert-sdk

v1.0.9

Published

Unofficial SDK for PushAlert.co

Downloads

32

Readme

PushAlert.co SDK

This package provides an unofficial SDK for sending notifications using the PushAlert.co service. It allows users to send notifications to their subscribers using the PushAlert.co API.

Disclaimer: This SDK is an unofficial implementation for interacting with the PushAlert.co service. While efforts have been made to ensure its functionality and reliability, please note that it does not have official support or endorsement from PushAlert.co.

Installation

Install the package using npm:

npm install pushalert-sdk

Usage

Import the SDK class from the package

import SDK from 'pushalert-sdk';

Create an instance of the SDK by providing your PushAlert.co API key:

const apiKey = 'YOUR_API_KEY';
const sdk = new SDK(apiKey);

Sending Notifications

Currently supported APIs:

  1. sendToSingle: This API allows you to send a notification to a single subscriber.

  2. sendToAll: With this API, you can broadcast a notification to all subscribers.

  3. sendToMultiple: This API allows you to send notifications to multiple subscribers simultaneously.

  4. sendWithCustomAttributes: This API allows you to send notifications to multiple subscribers simultaneously with custom attributes.

  5. getStats: This API allows you to get the stats of your notification.

  6. deleteNotification: This API allows you to delete a scheduled notification.

1. Send to All Subscribers

To send a notification to all subscribers, use the sendToAll method:

const options = {
  title: 'Your Title',
  message: 'Your Message',
  icon: 'http://yourwebsite.com/icon.png',
  url: 'https://yourwebsite.com',
};

sdk.sendToAll(options)
  .then(response => {
    console.log('Notification sent successfully:', response);
  })
  .catch(error => {
    console.error('Error sending notification:', error);
  });

2. Send to a Single Subscriber

To send a notification to a single subscriber, use the sendToSingle method:

const options = {
  title: 'Your Title',
  message: 'Your Message',
  icon: 'http://yourwebsite.com/icon.png',
  url: 'https://yourwebsite.com',
  subscriber: 'SUBSCRIBER_ID',
};

sdk.sendToSingle(options)
  .then(response => {
    console.log('Notification sent successfully:', response);
  })
  .catch(error => {
    console.error('Error sending notification:', error);
  });

3. Send to Multiple Subscribers

To send a notification to multiple subscribers, use the sendToMultiple method:

const options = {
  title: 'Your Title',
  message: 'Your Message',
  icon: 'http://yourwebsite.com/icon.png',
  url: 'https://yourwebsite.com',
  subscribers: ['SUBSCRIBER_ID1', 'SUBSCRIBER_ID2'],
};

sdk.sendToMultiple(options)
  .then(response => {
    console.log('Notification sent successfully:', response);
  })
  .catch(error => {
    console.error('Error sending notification:', error);
  });

4. Send to Multiple Subscribers with Custom Attributes

To send a notification to multiple subscribers with custom attributes, use the sendWithCustomAttributes method:

sdk.sendWithCustomAttributes({
  title: 'Test Custom Attributes',
    message: 'Test Custom Attributes',
    url: 'https://www.yourwebsite.com/',
}).then((res) => {
  console.log("Response");
  console.log(res);
}
).catch((err) => {
  console.log(err);
}
);

5. Get Stats of a Notification

To get the stats of a notification, use the getStats method:

sdk.getStats({id: 'NOTIFICATION_ID'})
  .then(response => {
    console.log('Notification stats:', response);
  })
  .catch(error => {
    console.error('Error getting notification stats:', error);
  });

6. Delete a Scheduled Notification

To delete a scheduled notification, use the deleteNotification method:

sdk.deleteNotification({id: 'NOTIFICATION_ID'})
  .then(response => {
    console.log('Notification deleted successfully:', response);
  })
  .catch(error => {
    console.error('Error deleting notification:', error);
  });