Send cross platform native notifications using Raycast
npm install raycast-notifierSend cross platform native notifications using Raycast
``shell`
npm i raycast-notifier
Run npx raycast-notifier-setup under your extension project directory to setup notifier prebuilds to the assets folder.
Remember to run preparePrebuilds() before you use any function from the raycast-notifier.
`tsx
import { useEffect, useState } from "react";
import { List } from "@raycast/api";
import { notificationCenter, preparePrebuilds } from "raycast-notifier";
export default function Command() {
const [isLoading, setIsLoading] = useState(true);
const loadPrebuilds = async () => {
await preparePrebuilds();
setIsLoading(false);
const result = await notificationCenter({
title: "Raycast Notifier",
subtitle: "Success",
message: "Hello from Raycast!",
reply: "Send greetings...",
});
const { response, metadata } = result;
if (response === "replied") {
console.log("Reply:", metadata?.activationValue);
}
};
useEffect(() => {
loadPrebuilds();
}, []);
return ;
}
`
This function programmatically copies the prebuilds files from assets/prebuilds to the correct directory for node-notifier.
This function is used to create a notify action of NotificationCenter.
Returns a Promise.
#### notifyOptions
Type: NotifyOptions
Optional. Options for node-notifier's notifier.notify(notifyOptions).
#### notifierOptions
Type: NotifierOptions
Optional. Options for node-notifier's new NotificationCenter(notifierOptions).
This method can be used to find the installed Notification Center from Raycast Notification.
Returns a Promise.
`typescript
import { open } from "@raycast/api";
import {
findRaycastNotificationCenterPath,
notificationCenter,
} from "raycast-notifier";
const found = await findRaycastNotificationCenterPath();
// ... You can lead user to the installation page if not found
open("raycast://extensions/maxnyby/raycast-notification");
notificationCenter(
notifyOptions,
// undefined here means use the its own Notification Center``
{ customPath: found },
);
See https://github.com/mikaelbr/node-notifier/issues/361#issuecomment-968916810.
This is a upstream issue from terminal-notifier.
- node-notifier - Send cross platform native notifications using Node.js
MIT