wtfaremyinitials / osa-imessage

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

Cant send messages on macOS (14.2.0) #31

Open trevoroleary opened 3 years ago

trevoroleary commented 3 years ago

I was using apple script to send messages before this but those scripts are seemingly broken as well. Anybody know what might have changed? This is the error I got when running the echo.js (I censored the phone number)

(node:29344) UnhandledPromiseRejectionWarning: Error: Command failed: /usr/bin/osascript -l JavaScript
execution error: Error: Error: no thread with handle '+14xxxxxxxx1' (-2700)

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
(node:29344) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:29344) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
3DJakob commented 3 years ago

I got the same problem! Any fix yet?

wtfaremyinitials commented 3 years ago

It looks like Apple may have (un?)intentionally broken that API. I’ll see what I can do

RandallKent commented 3 years ago

A couple of observations:

  1. Access to ~/Library/Messages/ has been restricted in Catalina (blog)
  2. buddies have become participants

Screen Shot 2021-02-21 at 11 18 52 y1KFOlLQ-62hvuicj-9Aq0T3VE

I was able to get echo.js to work by granting access to ~/Library/Messages/ and changing index.js:104 from

target = Messages.buddies.whose({ handle: handle })[0]

to

target = Messages.participants.whose({ handle: handle })[0]