wtfaremyinitials / osa-imessage

Send and receive iMessages with nodejs
MIT License
324 stars 54 forks source link

Can't get this to work! #1

Closed irfaan closed 8 years ago

irfaan commented 9 years ago

I am getting the following error:

undefined:1
��{
^
SyntaxError: Unexpected token �
    at Object.parse (native)
    at LineStream.<anonymous> (/[PATH]/node_modules/osa-imessage/index.js:45:21)
    at LineStream.emit (events.js:95:17)
    at LineStream.<anonymous> (_stream_readable.js:764:14)
    at LineStream.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:426:10)
    at emitReadable (_stream_readable.js:422:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at LineStream.Readable.push (_stream_readable.js:127:10)
    at LineStream.Transform.push (_stream_transform.js:140:32)

Related to this? https://github.com/jahewson/node-byline/issues/17

I even tried restricting byline to v 4.1.1 On node v.0.10.31 (the latest version threw errors) and same error on node v.0.10.3 (see the issue linked above).

Any ideas?

EDIT Hacked around for a temporary solution:

var re = /\0/g;
var data = JSON.parse(data.toString().substr(2).replace(re, ""));
wtfaremyinitials commented 9 years ago

Hm. Does this occur when sending or receiving messages?

irfaan commented 9 years ago

receiving.

The hack actually reads like this now to accommodate email as handle:

data = data.toString();

if(data.substr(0,1) == "{"){
    data = JSON.parse(data);
}else{
    var re = /\0/g;
    var data = JSON.parse(data.substr(2).replace(re, ""));
}
wtfaremyinitials commented 9 years ago

You're welcome to PR that fix if it's stable

irfaan commented 9 years ago

Alright. I'll do that. It appears so.

Also, two other issues I'm having:

  1. It ignores the first message sent from a handle that it hasn't received a message from before. No error thrown.
  2. Messages.send() throws the following if I'm sending to a handle that it has never sent/received a message to/from before:
{ [Error: Command failed: 0:708: execution error: Error on line 1: Error: Can't get object. (-1728)
] killed: false, code: 1, signal: null }
wtfaremyinitials commented 9 years ago

Odd. I'll do some investigating in a bit.

wtfaremyinitials commented 9 years ago

Well this is a shame. I can't get Xcode working right now, and compiling mkfifo requires xcode. I won't be able to finish all this for another couple days.

wtfaremyinitials commented 8 years ago

Closing because at this point the receiving messages API is removed as far as I know.