A node.js module to interact with iMessage.
Developed for the webmessage project that aims to bring an iMessage client to the browser
Requires OSX 10.10 Yosemite.
npm install osa-imessage
###Sending messages
Send a message to a phone number:
var messages = require('osa-imessage');
messages.send('Hello World!', '+15555555555', callback);
Send a message to a contact:
var messages = require('osa-imessage');
messages.send('Hello World!', 'Johnny Appleseed', callback);
Send a message to an iCloud account:
var messages = require('osa-imessage');
messages.send('Hello World!', 'john@icloud.com', callback);
###Receiving messages
var messages = require('osa-imessage');
var messageEvents = messages.listen();
// After messages.listen() is called, osa-imessage must be set
// as the AppleScript handler in Messages.app's preferences page
messageEvents.on('received', function(data){
var message = data.text; // "Hello, World!"
var fromName = data.from.name; // "Johnny Appleseed"
var fromHandle = data.from.handle; // "john@icloud.com"
var time = data.time; // Timestamp
});