• Stars
    star
    324
  • Rank 129,708 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 10 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Send and receive iMessages with nodejs

osa-imessage

styled with prettier

Send and receive iMessages through nodejs

Installation

Requires OSX 10.10 Yosemite

npm install osa-imessage --save

Usage

Be sure to require osa-imessage:

const imessage = require('osa-imessage')

Send a message

imessage.send('+15555555555', 'Hello World!')

Receive messages

imessage.listen().on('message', (msg) => {
    if (!msg.fromMe) console.log(`'${msg.text}' from ${msg.handle}`)
})

Send message to name

imessage.handleForName('Tim Cook').then(handle => {
    imessage.send(handle, 'Hello')
})

Send message to group

imessage.send('chat000000000000000000', 'Hello everyone!')

Get recent chats

imessage.getRecentChats(20) // Defaults to 10

API

Send a message

send(handle, text) -> Promise

Sends a message to the specified handle.

handle

Type: string

The user or group to send the message to, in one of the following forms:

  • phone number (+1555555555)
  • email address ([email protected])
  • group chat id (chat000000000000000000)

text

Type: string

The content of the message to be sent.

return

Type: Promise<>

A promise that resolves when the message is sent, and rejects if the message fails to send.

Receive messages

listen([interval]) -> EventEmitter

Begins polling the local iMessage database for new messages.

interval

Type: number

The rate at which the database is polled for new messages. Defaults to the minimum of 1000 ms.

return

Type: EventEmitter

An event emitter with that listeners can be attached to. Currently it only has the message event.

Example message event

{
    text: 'Hello, world!',
    handle: '+15555555555',
    group: null,
    date: new Date('2017-04-11T02:02:13.000Z'),
    fromMe: false,
    guid: 'F79E08A5-4314-43B2-BB32-563A2BB76177'
}

Example group message event

{
    text: 'Hello, group!',
    handle: '+15555555555',
    group: 'chat000000000000000000',
    date: new Date('2017-04-23T21:18:54.943Z'),
    fromMe: false,
    guid: 'DCFE0EEC-F9DD-48FC-831B-06C75B76ACB9'
}

Get a handle for a given name

handleForName(name) -> Promise<handle>

name

Type: string

The full name of the desired contact, as displayed in Messages.app.

return

Type: Promise<string>

A promise that resolves with the handle of the contact, or rejects if nobody was found.

Get the name associated with a given handle

nameForHandle(handle) -> Promise<name>

handle

Type: string

The handle of a contact.

return

Type: Promise<string>

A promise that resolved with the full name of the desired contact, as displayed in Messages.app.

Get recents chats

getRecentChats(limit) -> Promise

limit

Type: integer

Amount of recent chats to return.

return

Type: Promise

A promise that resolves with an array of chats.

More Repositories

1

jxa

Access macOS JavaScript for Automation APIs directly in node
JavaScript
304
star
2

osa2

Interact with Apple's Open Scripting Architecture in node.js
JavaScript
59
star
3

BloonsTowerDefense6

Remake of the popular flash game Bloons Tower Defense with Java Greenfoot
Java
13
star
4

iconutil

Convert between PNG/Iconsets and .ICNS files with NodeJS
JavaScript
12
star
5

minecraft-schematic

Read and write Minecraft schematic files
JavaScript
12
star
6

osa-spotify

Bring the power of Node.JS to Spotify on OSX
JavaScript
7
star
7

osa-omnifocus

JavaScript
4
star
8

KitchenSink

A centralized database for Sponge plugins and mods
JavaScript
4
star
9

monktype

Increase typing speed by re-creating existing text files
Rust
3
star
10

osa-contacts

Access contact information on OSX with Node.JS
JavaScript
3
star
11

lambda-rust

Run Rust code in AWS Lambda
Rust
2
star
12

blocking-await

Synchronously wait for a Promise to resolve
JavaScript
2
star
13

uint4

Read and write half-bytes to buffers
JavaScript
2
star
14

js-features-used

Detect the JavaScript language features used in code
JavaScript
2
star
15

pcmrwatermark

PCMR Watermark Tool
JavaScript
1
star
16

coinado-node

Download torrents via Coinado's HTTP API
JavaScript
1
star
17

WireDOM

Manipulate the DOM with Javascript variables
JavaScript
1
star
18

deno-shell-tag

The simplest way to use a *nix tools in deno. let files = await sh`ls -a`
JavaScript
1
star
19

Teenager_Bot

/u/teenager_bot for the /r/teenagers subreddit
Python
1
star
20

gulp-literate

Markdown files that happen to contain source code
JavaScript
1
star
21

openfocus

Command line client for OmniFocus written in Rust
Rust
1
star
22

Duties

A generator based task scheduler
JavaScript
1
star
23

node-powerschool

Get PowerSchool student data with Node.JS
JavaScript
1
star
24

deasync-napi

C
1
star
25

webmessage

Send iMessages with a web browser
JavaScript
1
star
26

npm-r

a faster npm run
Shell
1
star
27

webvtt.js

Javascript lib to create and modify WebVTT files
JavaScript
1
star
28

stream-pipeline

Dynamically add and remove streams from a pipe chain
JavaScript
1
star
29

PowerNode

A Node.JS module to interface with PowerSchool
JavaScript
1
star
30

CAD-Final-Phone-Case

My CAD Class Final Project
1
star
31

InjectJS

A library for manipulating Javascript functions at runtime
JavaScript
1
star