Send cross platform native notifications using Raycast
npm i raycast-notifierRun 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.
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 <List isLoading={isLoading} />;
}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<NotifyResult>.
Type: NotifyOptions
Optional. Options for node-notifier's notifier.notify(notifyOptions).
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<string | undefined>.
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, { customPath: found });See mikaelbr/node-notifier#361 (comment).
This is a upstream issue from terminal-notifier.
- node-notifier - Send cross platform native notifications using Node.js
- terminal-notifier - The command-line tool to send macOS User Notifications
- raycast-corss-extension - Defines the development approach for cross-extension in Raycast
- raycast-hid - Access USB & Bluetooth HID devices through Node.js
MIT