Bark.js is a simple JavaScript library for sending custom notifications to your iPhone using the Bark iOS App.
- Send custom push notifications with various options
- Easy to use and integrate
npm install @thiskyhan/bark.js
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);
});
Creates an instance of BarkClient
.
options
(BarkOptions): Configuration options for the client.baseUrl
(string): Bark server base URL.key
(string): Device key for authentication.
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.
We welcome contributions from the community! If you'd like to contribute to the project, please follow these guidelines:
- Fork the repository and clone it locally.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure the code passes any existing tests.
- Commit your changes with descriptive commit messages that follow the Conventional Commits standard.
- 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.
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!
This project is licensed under The GNU General Public License v3.0.
- Bark - The iOS App for push notifications