1.0.0 • Published 5 months ago

mkt-notification-utils v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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 NameURL
ENGAGEfile-sounds-760-engaged.ogg
SUNNYfile-bb_sunny.ogg
ALARMINGfile-sounds-738-alarming.ogg
CUCKOOfile-5b_cuckoo-clock-2.ogg
INFORMEDfile-sounds-751-youve-been-informed.ogg
NEW_FOR_YOUfile-sounds-1253-asmr-girl-i-got-news-for-you.ogg

🖼️ Available Icons

import { NotificationIcons } from "mkt-notification-utils";

console.log(NotificationIcons);
Icon NamePreview
ALARMAlarm
BELLBell
MESSAGEMessage
ROBOTRobot
BOMBBomb

📜 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