{"id":20100467,"url":"https://github.com/felixrieseberg/electron-windows-notifications","last_synced_at":"2025-04-05T07:02:31.998Z","repository":{"id":15351386,"uuid":"69281571","full_name":"felixrieseberg/electron-windows-notifications","owner":"felixrieseberg","description":":zap: Send native Windows WinRT notifications from Electron","archived":false,"fork":false,"pushed_at":"2022-03-22T08:49:09.000Z","size":354,"stargazers_count":266,"open_issues_count":27,"forks_count":40,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-29T06:04:47.042Z","etag":null,"topics":["electron","notifications","windows"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felixrieseberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-26T18:45:56.000Z","updated_at":"2025-03-20T06:15:47.000Z","dependencies_parsed_at":"2022-09-26T22:10:17.036Z","dependency_job_id":null,"html_url":"https://github.com/felixrieseberg/electron-windows-notifications","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixrieseberg%2Felectron-windows-notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixrieseberg%2Felectron-windows-notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixrieseberg%2Felectron-windows-notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixrieseberg%2Felectron-windows-notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixrieseberg","download_url":"https://codeload.github.com/felixrieseberg/electron-windows-notifications/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299829,"owners_count":20916190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","notifications","windows"],"created_at":"2024-11-13T17:15:51.726Z","updated_at":"2025-04-05T07:02:31.979Z","avatar_url":"https://github.com/felixrieseberg.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# electron-windows-notifications\nCreate native Windows toast and tile notifications for Windows 8, 8.1, and 10 using native bindings to WinRT (using NodeRT).\n\n```\nnpm install --save electron-windows-notifications\n```\n\nFrom Electron v14 on, you'll have to require NodeRT modules in the `main` process. See https://github.com/NodeRT/NodeRT/issues/158 for details.\n\n### Usage\nFor more samples, check out the `samples` folder.\n\n\u003e :memo: 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](https://github.com/felixrieseberg/electron-windows-interactive-notifications)!\n\n\u003e :memo: Want to check if _you should send a notification?_, accounting for the user notification state and quiet hours? Check out [electron-notification-state](https://github.com/felixrieseberg/electron-notification-state).\n\n#### ToastNotification\nThe constructor for the `ToastNotification` class accepts an options `object` with the following properties:\n\n * `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](samples/template.js)\n * `string[]` strings - An array of strings to be used in your template. XML escaping is applied to all strings.\n * `Date` expirationTime - Time after which a toast notification should not be displayed.\n * `string` group - Group identifier for the notification.\n * `string` tag - Unique identifier of this notification within the notification group.\n * `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.\n\n```JS\nconst appId = 'electron-windows-notifications'\nconst {ToastNotification} = require('electron-windows-notifications')\n\nlet notification = new ToastNotification({\n    appId: appId,\n    template: `\u003ctoast\u003e\u003cvisual\u003e\u003cbinding template=\"ToastText01\"\u003e\u003ctext id=\"1\"\u003e%s\u003c/text\u003e\u003c/binding\u003e\u003c/visual\u003e\u003c/toast\u003e`,\n    strings: ['Hi!']\n})\n\nnotification.on('activated', () =\u003e console.log('Activated!'))\nnotification.show()\n```\n\n#### TileNotification\nTile 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`](https://github.com/felixrieseberg/electron-windows-store). The constructor for the `TileNotification` class accepts an options `object` with the following properties:\n\n * `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](samples/template.js)\n * `string[]` strings - An array of strings to be used in your template. XML escaping is applied to all strings.\n * `string` tag - Unique identifier of this notification within the notification group.\n * `string` tileId - If set, the given tile will be updated. Otherwise, the app's primary tile will be used.\n\n```JS\nconst appId = 'electron-windows-notifications'\nconst {ToastNotification} = require('electron-windows-notifications')\n\nlet notification = new ToastNotification({\n    appId: appId,\n    template: `\u003ctoast\u003e\u003cvisual\u003e\u003cbinding template=\"ToastText01\"\u003e\u003ctext id=\"1\"\u003e%s\u003c/text\u003e\u003c/binding\u003e\u003c/visual\u003e\u003c/toast\u003e`,\n    strings: ['Hi!']\n})\n\nnotification.on('activated', () =\u003e console.log('Activated!'))\nnotification.show()\n```\n\n### Hints\n\n##### appUserModelId\nThe 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.\n\n##### Mysterious Failures \u0026 XML Escaping\nMicrosoft 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.\n\n##### String replacement\nInside 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:\n\n* %s - String.\n* %d - Number (both integer and float).\n* %j - JSON.\n* %% - single percent sign ('%'). This does not consume an argument.\n\n### License\nMIT. Please see LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixrieseberg%2Felectron-windows-notifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixrieseberg%2Felectron-windows-notifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixrieseberg%2Felectron-windows-notifications/lists"}