Skip to content

Instantly share code, notes, and snippets.

@jphungcode
Last active June 2, 2022 10:23
Show Gist options
  • Save jphungcode/c97ac0303a687ac1f846f16ac14f53f3 to your computer and use it in GitHub Desktop.
Save jphungcode/c97ac0303a687ac1f846f16ac14f53f3 to your computer and use it in GitHub Desktop.
electron notifications
// main.js
import {systemPreferences} from "electron"
app.whenReady().then(async () => {
systemPreferences.subscribeNotification(
"subscribeEvent",
(event, userInfo) => {
console.log(userInfo);
},
);
// you would probably embed this in a ipcMain event call to hook up to UI
systemPreferences.postNotification(
"postEvent",
{
// some data
foo: "bar"
},
true,
);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment