mac-notifier
v1.1.1
Published
A simple Node.js library to send iMessages and use macOS's speech synthesis.
Maintainers
Readme
mac-notifier
A simple Node.js library to send iMessages and use macOS's speech synthesis, now with rich iMessage support.
Installation
yarn add mac-notifier
# or
npm install mac-notifierConfiguration
Create a .env file in the root of your project with the following environment variables:
MAC_NOTIFIER_PHONE=+1234567890 # Your personal phone number (the recipient for iMessages)Usage
Command Line Interface (CLI)
./cli.js "Your message here"
# Send a message and speak it
./cli.js "Hello world" all
# Send a message only via iMessage
./cli.js "Hello iMessage" message
# Speak a message only
./cli.js "Hello spoken" say
# Send a rich iMessage with a link
./cli.js "Check this out" --linkUrl "https://www.google.com" --rich
# Send a rich iMessage with an image URL
./cli.js "Here's an image" --imageUrl "https://example.com/image.png" --rich
# Send a rich iMessage with both image URL and link
./cli.js "Rich content!" --imageUrl "https://example.com/image.png" --linkUrl "https://www.google.com" --richProgrammatic Usage
const { notify, notifyEx, Level } = require('mac-notifier');
// Basic notification (iMessage and/or speech)
notify('Hello from Node.js!', Level.All);
// Send a rich iMessage
notifyEx({
message: 'Check out this product!',
phoneNumber: '+1234567890', // Optional: overrides MAC_NOTIFIER_PHONE from .env
imageUrl: 'https://example.com/product.png',
linkUrl: 'https://example.com/product-page',
});
// Speak a message
notify('This will be spoken.', Level.Say);Publishing to npm
To publish this package to npm, follow these steps:
Log in to npm:
npm loginFollow the prompts to enter your npm username, password, and email.
Update version (if necessary): Before publishing, you might want to update the package version in
package.json.npm version <major|minor|patch>For example,
npm version patchwill increment the patch version (e.g., from1.0.0to1.0.1).Publish the package:
npm publishThis will publish your package to the npm registry. Ensure you are in the root directory of your project when running this command.
Verify: After publishing, you can check if your package is available on npm by visiting
https://www.npmjs.com/package/mac-notifier(replacemac-notifierwith your package name if different).
