Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

chrome-notifications

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

chrome-notifications

Helper for chrome.notifications API.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

chrome-notifications

npm version build License

ko-fi

Overview

Helper for chrome.notifications API.

Notes

Installation

You can install this library using npm:

npm install chrome-notifications

Methods

create

Creates and displays a notification.

import { Notifications } from "chrome-notifications";

const options = {
  type: "basic",
  title: "My Notification",
  message: "This is a sample notification",
  iconUrl: "icon.png",
};

Notifications.create(options, "my-notification-id", (notification) => {
  console.log(notification);
});

// Output:
//   Object{
//     notificationId: "38fde96f-43b1-4736-969e-2da10417c024",
//     type: "basic",
//     title: "My Notification",
//     message: "This is a sample notification",
//     iconUrl: "icon.png"
//   }

update

Updates an existing notification.

import { Notifications } from "chrome-notifications";

const notificationId = "38fde96f-43b1-4736-969e-2da10417c024";
const newOptions = {
  title: "Updated Notification",
  message: "This is an updated notification",
};

Notifications.update(notificationId, newOptions, (notification) => {
  console.log(notification);
});

// Output:
//   Object{
//     notificationId: "38fde96f-43b1-4736-969e-2da10417c024",
//     type: "basic",
//     title: "Updated Notification",
//     message: "This is an updated notification",
//     iconUrl: "icon.png"
//   }

clear

Clears the specified notification.

import { Notifications } from "chrome-notifications";

const notificationId = "38fde96f-43b1-4736-969e-2da10417c024";

Notifications.clear(notificationId, (wasCleared) => {
  console.log(wasCleared);
});

// Output: true

getAll

Retrieves all the notifications of this app or extension.

import { Notifications } from "chrome-notifications";

Notifications.getAll().then((notifications) => {
  console.log(notifications);
});

// Output:
//   Array [
//     Object {
//       notificationId: "131aa054-c1b3-485b-a200-83bdcba8421c",
//       active: true
//     }
//   ]

getPermissionLevel

Retrieves whether the user has enabled notifications from this app or extension.

import { Notifications } from "chrome-notifications";

Notifications.getPermissionLevel().then((permissionLevel) => {
  console.log(permissionLevel);
});

// Output:
//   Object{
//     level: "granted",
//     isGranted: true,
//     isDenied: false
//   }

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

chrome

FAQs

Package last updated on 31 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts