notify-manager-electron
v1.5.0
Published
Create beautiful and functional notifications on electron
Maintainers
Readme
Notify Manager
Info
You can test the library with npm run test or npm run test.reply. And also see the source code of examples
Approximate result:
You can change the appearance of the notification by adding your style when creating the NotifyManager
You can use your own sounds when showing a notification.
Demo
Standart notify
Example: Click
Demo:
https://github.com/zxcnoname666/notify-manager-electron/assets/156155219/57532a45-d0d2-46bf-bf6f-ba21df3a799b
Reply notify
Example: Click
Demo:
https://github.com/zxcnoname666/notify-manager-electron/assets/156155219/3d0215f1-31c1-436f-84c9-48c9bb58573b
How to use
Creating a NotifyManager
// 1 - bottom-right;
// 2 - top-right;
// 3 - top-left;
// 4 - bottom-left;
const _manager = new NotifyManager(1, '/* your custom style */');Creating a Notify
Basic notify
const notify = new Notify('Title of notify', 'Body of notify. HTML allowed.');
// show notify
_manager.show(notify);Hook onDestroy of notify
const notify = new Notify('Test notify', 'Test.');
notify.onDestroy(() => console.log('destroyed'));
notify.onDestroy(() => console.log('2nd console log of notify destroy'));
// show notify
_manager.show(notify);Hook onclick of notify
const notify = new Notify('Click hook', 'Click on the notify.');
// show notify
_manager.show(notify, () => {
console.log('clicked on the notify');
//..... other code
});Open an external link when click on the notify
const { shell } = require('electron');
const notify = new Notify('Click hook', 'Click to open link');
_manager.show(notify, () => shell.openExternal('https://github.com/zxcnoname666/notify-manager-electron'));Notification with image & custom duration
Recommended image size - 55x55px
const duration = 30; // in seconds
const notify = new Notify('Your App', 'Your beautiful message', duration, 'https://github.com/favicon.ico');
// show notify
_manager.show(notify);Notify with sound
Attention: It is not recommended to use music playing for a long time. Instead, use sounds up to 10 seconds long.
// url, volume
const sound = new NotifySound('https://github.com/zxcnoname666/repo-files/raw/main/notify-manager-electron/meow1.mp3', 50);
const body = '<span style="color:red !important;">text</span>';
const image = 'https://github.com/zxcnoname666/SoundCloud-Desktop/raw/main/icons/appLogo.png';
const notify = new Notify('notify with sound & html', body, 60, image, sound);
// show notify
_manager.show(notify);