1.0.0 • Published 5 months ago
mkt-notification-utils v1.0.0
MKT - Notification Utils 🔔
mkt-notification-utils is a lightweight, dependency-free JavaScript utility for handling browser notifications with ease. It provides customizable notifications with icons, sounds, vibrations, and click events, allowing seamless integration into web applications.
🚀 Features
- ✅ Simple API - Trigger notifications with just one function call.
- ✅ Custom Icons & Sounds - Choose from predefined options or use your own.
- ✅ Click Actions - Handle user interaction when clicking notifications.
- ✅ Vibration Support - Define custom vibration patterns (mobile support).
- ✅ Permission Handling - Request browser notification permission automatically.
- ✅ No Dependencies - Pure JavaScript implementation.
📦 Installation
To install via npm, run:
npm install mkt-notification-utils
🎯 Quick Start
1️⃣ Import the module and initialize it
import { notificationUtil } from "mkt-notification-utils";
// Initialize permissions
notificationUtil.init();
2️⃣ Basic Notification
notificationUtil.notify({
message: "Hello, world!"
});
🔔 Advanced Usage
📌 Notification with Custom Title & Sound
import { NotificationSounds } from "mkt-notification-utils";
notificationUtil.notify({
title: "New Message",
message: "You have a new notification!",
sound: NotificationSounds.ALARMING
});
📌 Notification with Custom Icon & Click Event
import { NotificationIcons } from "mkt-notification-utils";
notificationUtil.notify({
title: "Click Me!",
message: "Click to open Google",
icon: NotificationIcons.ROBOT,
onClick: () => window.open("https://google.com", "_blank")
});
📌 Notification with Vibration (Mobile Support)
notificationUtil.notify({
message: "This notification will vibrate!",
vibrate: [200, 100, 200]
});
🎨 Customization
🔊 Available Sounds
import { NotificationSounds } from "mkt-notification-utils";
console.log(NotificationSounds);
Sound Name | URL |
---|---|
ENGAGE | file-sounds-760-engaged.ogg |
SUNNY | file-bb_sunny.ogg |
ALARMING | file-sounds-738-alarming.ogg |
CUCKOO | file-5b_cuckoo-clock-2.ogg |
INFORMED | file-sounds-751-youve-been-informed.ogg |
NEW_FOR_YOU | file-sounds-1253-asmr-girl-i-got-news-for-you.ogg |
🖼️ Available Icons
import { NotificationIcons } from "mkt-notification-utils";
console.log(NotificationIcons);
Icon Name | Preview |
---|---|
ALARM | ![]() |
BELL | ![]() |
MESSAGE | ![]() |
ROBOT | ![]() |
BOMB | ![]() |
📜 License
This project is licensed under the MIT License.
🚀 Contributing
Pull requests are welcome! If you’d like to improve the library, please open an issue first to discuss changes.
1.0.0
5 months ago