All Projects → felixrieseberg → Electron Windows Notifications

felixrieseberg / Electron Windows Notifications

Licence: mit
⚡️ Send native Windows WinRT notifications from Electron

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Electron Windows Notifications

Timeago
This will help to get how much time have passed. Useful in showing messages, notifications time and etc.
Stars: ✭ 169 (-17.96%)
Mutual labels:  notifications
Shoutrrr
Notification library for gophers and their furry friends.
Stars: ✭ 177 (-14.08%)
Mutual labels:  notifications
Hawkeye
A useful app for GitHub Notifications
Stars: ✭ 193 (-6.31%)
Mutual labels:  notifications
Web Push Php Example
An example for sending Web Push notifications, using web-push-php
Stars: ✭ 173 (-16.02%)
Mutual labels:  notifications
React Notify Toast
Toast notifications for React.js
Stars: ✭ 176 (-14.56%)
Mutual labels:  notifications
Dllocalnotifications
💬 Easily create Local Notifications in swift - Wrapper of UserNotifications Framework
Stars: ✭ 182 (-11.65%)
Mutual labels:  notifications
Bitprophet
Node crypto trading platform for Binance exchange.
Stars: ✭ 166 (-19.42%)
Mutual labels:  notifications
Notify Send.sh
drop-in replacement for notify-send with more features
Stars: ✭ 200 (-2.91%)
Mutual labels:  notifications
Googlecontactseventsnotifier
Receive automatic email notifications before your Google Contacts birthday and other events!
Stars: ✭ 177 (-14.08%)
Mutual labels:  notifications
Ng2 Notifications
Angular 2 Component for Native Push Notifications [Looking for New Maintainers]
Stars: ✭ 192 (-6.8%)
Mutual labels:  notifications
Amplify Cli
The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Stars: ✭ 2,399 (+1064.56%)
Mutual labels:  notifications
Angular Notifier
A well designed, fully animated, highly customizable, and easy-to-use notification library for your Angular application.
Stars: ✭ 175 (-15.05%)
Mutual labels:  notifications
Python Notifyall
A library which can be used for all types of notifications like SMS, Mail, Push.
Stars: ✭ 185 (-10.19%)
Mutual labels:  notifications
Notiflix
Notiflix is a JavaScript library for client-side non-blocking notifications, popup boxes, loading indicators, and more that makes your web projects much better.
Stars: ✭ 172 (-16.5%)
Mutual labels:  notifications
Apns Http2
A Java library for sending notifications via APNS using Apple's HTTP/2 API.
Stars: ✭ 194 (-5.83%)
Mutual labels:  notifications
Ember Cli Notifications
⚛ Atom inspired notification messages for ember-cli
Stars: ✭ 168 (-18.45%)
Mutual labels:  notifications
Cmus Osx
Adds track change notifications, and media key support to cmus.
Stars: ✭ 179 (-13.11%)
Mutual labels:  notifications
Uptime Monitor App
A PHP application to monitor uptime and ssl certificates
Stars: ✭ 205 (-0.49%)
Mutual labels:  notifications
Budgie Desktop
I Tawt I Taw A Purdy Desktop
Stars: ✭ 2,374 (+1052.43%)
Mutual labels:  notifications
Sweetalert2
A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies.
Stars: ✭ 13,929 (+6661.65%)
Mutual labels:  notifications

electron-windows-notifications

Create native Windows toast and tile notifications for Windows 8, 8.1, and 10 using native bindings to WinRT (using NodeRT).

npm install --save electron-windows-notifications

Usage

For more samples, check out the samples folder.

📝 Want to respond to interactive notifications (with input fields, for instance)? You can send them with this module - and respond to them with electron-windows-interactive-notifications!

📝 Want to check if you should send a notification?, accounting for the user notification state and quiet hours? Check out electron-notification-state.

ToastNotification

The constructor for the ToastNotification class accepts an options object with the following properties:

  • string template - The XML template for the notification. You can also call new Template() with few properties to customize your own XML template based on the default. See example: template.js
  • string[] strings - An array of strings to be used in your template. XML escaping is applied to all strings.
  • Date expirationTime - Time after which a toast notification should not be displayed.
  • string group - Group identifier for the notification.
  • string tag - Unique identifier of this notification within the notification group.
  • string appId - appUserModelId of the application for which the notification is sent. If not passed, it will be assumed to be a global property in Electron's main thread.
const appId = 'electron-windows-notifications'
const {ToastNotification} = require('electron-windows-notifications')

let notification = new ToastNotification({
    appId: appId,
    template: `<toast><visual><binding template="ToastText01"><text id="1">%s</text></binding></visual></toast>`,
    strings: ['Hi!']
})

notification.on('activated', () => console.log('Activated!'))
notification.show()

TileNotification

Tile notifications update the app's primary or secondary tiles. They require that the app is running inside the UWP model, which is possible on Windows 10 Anniversary Update and later. For more information, check out electron-windows-store. The constructor for the TileNotification class accepts an options object with the following properties:

  • string template - The XML template for the notification. You can also call new Template() with few properties to customize your own XML template based on the default. See example: template.js
  • string[] strings - An array of strings to be used in your template. XML escaping is applied to all strings.
  • string tag - Unique identifier of this notification within the notification group.
  • string tileId - If set, the given tile will be updated. Otherwise, the app's primary tile will be used.
const appId = 'electron-windows-notifications'
const {ToastNotification} = require('electron-windows-notifications')

let notification = new ToastNotification({
    appId: appId,
    template: `<toast><visual><binding template="ToastText01"><text id="1">%s</text></binding></visual></toast>`,
    strings: ['Hi!']
})

notification.on('activated', () => console.log('Activated!'))
notification.show()

Hints

appUserModelId

The appUserModelId identifies application in Windows. In Electron, you can set it at runtime using the app.setAppUserModelId() method. If you don't pass it, this module will assume that it's a property on Electron's main thread. Unless running inside a UWP container, you probably want to pass it.

Mysterious Failures & XML Escaping

Microsoft follows the XML spec to the letter - and XML has escaping rules you might not be familiar with. If you're adding strings and properties to your template, consider just using the strings property in the constructor - it will automatically properly escape all input.

String replacement

Inside the module, util.format is used. It'll format the template in a printf-like format. The template is expected to hold zero or more placeholders. Each placeholder is replaced with the converted value from its corresponding argument. If the placeholder does not have a corresponding argument, the placeholder is not replaced. Supported placeholders are:

  • %s - String.
  • %d - Number (both integer and float).
  • %j - JSON.
  • %% - single percent sign ('%'). This does not consume an argument.

License

MIT. Please see LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].