Skip to content

Bark.js is a simple JavaScript library for sending custom notifications to your iPhone using the Bark iOS App.

License

Notifications You must be signed in to change notification settings

chimpdev/bark.js

Repository files navigation

bark.js

Bark.js Logo

Bark.js is a simple JavaScript library for sending custom notifications to your iPhone using the Bark iOS App.


Table of Contents

Features

  • Send custom push notifications with various options
  • Easy to use and integrate

Installation

npm install @thiskyhan/bark.js

Usage

import { BarkClient, BarkPushPayload } from 'bark.js';

// Configure the Bark client
const options = {
  baseUrl: 'https://your-bark-server.com', // You can also http://api.day.app as the base URL for the official Bark server
  key: 'your-device-key'
};

const client = new BarkClient(options);

// Create a notification payload
const payload = {
  body: 'Hello, this is a test notification!',
  title: 'Test Notification',
  icon: 'https://example.com/icon.jpg',
  url: 'https://example.com'
};

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

API

BarkClient

constructor(options: BarkOptions)

Creates an instance of BarkClient.

  • options (BarkOptions): Configuration options for the client.
    • baseUrl (string): Bark server base URL.
    • key (string): Device key for authentication.

pushMessage(payload: BarkPushPayload): Promise<BarkResponse>

Sends a push notification via the Bark API.

  • payload (BarkPushPayload): The notification payload to send.
    • body (string): Content of the push notification (required).
    • title (string): Title of the push notification (optional).
    • icon (string): Icon URL for the notification (optional, must be a JPG image).
    • url (string): URL to open when the notification is clicked (optional, must be a valid URL).
    • Other optional fields as defined in the BarkPushPayload interface.

Contributing

We welcome contributions from the community! If you'd like to contribute to the project, please follow these guidelines:

  1. Fork the repository and clone it locally.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and ensure the code passes any existing tests.
  4. Commit your changes with descriptive commit messages that follow the Conventional Commits standard.
  5. Push your changes to your fork and submit a pull request to the main branch of the original repository.

Please make sure to follow the Code of Conduct and Contributing Guidelines when contributing to this project.

Help

If you encounter any issues with the Lantern or have any questions, feel free to open an issue on this repository. We'll do our best to assist you!

License

This project is licensed under The GNU General Public License v3.0.

Acknowledgements

  • Bark - The iOS App for push notifications

About

Bark.js is a simple JavaScript library for sending custom notifications to your iPhone using the Bark iOS App.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published