Skip to content

AshikNesin/send-push-notification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Send Push Notification Package

This package provides a simple way to send notifications using the Pushover service. It exports a single function, sendPushOverNotification, which you can use to send a notification with a given payload.

Installation

To install the package, use your favorite package manager:

npm install --save send-push-notification

or

yarn add send-push-notification

Usage

First, you need to set your Pushover user key and API token as environment variables:

export PUSHOVER_USER_KEY=your_user_key
export PUSHOVER_API_TOKEN=your_api_token

Then, you can use the sendPushOverNotification function to send a notification:

import { sendPushOverNotification } from 'send-push-notification';

const payload = {
    message: 'Hello, World!',
    title: 'My First Notification',
    // Other optional parameters: https://pushover.net/api#messages
};

sendPushOverNotification(payload)
    .then(response => {
        console.log('Notification sent successfully:', response);
    })
    .catch(error => {
        console.error('Failed to send notification:', error);
    });

Error Handling

In case of an error, the function will throw an error with a descriptive message. You can handle the error using a try-catch block or with a .catch() method in a promise chain.

API Reference

For more information about the Pushover API and the available parameters, please refer to the official Pushover API documentation.

License

This package is licensed under the MIT License.

About

A lightweight and easy-to-use Node.js package for sending notifications via the Pushover service

Topics

Resources

Stars

Watchers

Forks