wtfaremyinitials / osa-imessage

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

Unable to send text #20

Closed svenyonson closed 6 years ago

svenyonson commented 6 years ago

using the example from the readme in file:

const imessage = require('osa-imessage');
imessage.send('+<mycellnumber>', 'Hello World!')

fails with this error:

svens-mbp:osa-test svenyonson$ node test.js

(node:21987) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 
1): Error: Command failed: /usr/bin/osascript -l JavaScript
445:509: execution error: Error on line 19: Error: no thread with handle '+<mycellnumber>' (-2700)

(node:21987) [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.
KarinaFernandez commented 6 years ago

Hi @svenyonson ! I tried to send a message without success too, but I think that my problem is that I am executing it at anywhere. Could you please tell me where are you running the command imessage.send('+<mycellnumber>', 'Hello World!')?

Thanks in advance!

wtfaremyinitials commented 6 years ago

Have you send an iMessage to that phone number using your Mac before?

svenyonson commented 6 years ago

I'm sending it from my Mac, to my phone, in a simple Node.js script. Tryed the code interactively and from a .js file.

On Dec 22, 2017, at 12:57 PM, Will Franzen notifications@github.com wrote:

Have you send an iMessage to that phone number using your Mac before?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wtfaremyinitials/osa-imessage/issues/20#issuecomment-353646938, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWlLgYNBPqTYSs2aqed5106AzPCcnU1ks5tC-2CgaJpZM4RGYBE.

wtfaremyinitials commented 6 years ago

Try sending a message to your phone via your Mac with the built in Messages app before trying osa-imessage

svenyonson commented 6 years ago

Yes. Works fine.

Sent from my iPhone

On Dec 25, 2017, at 2:22 PM, Will Franzen notifications@github.com wrote:

Try sending a message to your phone via your Mac with the built in Messages app before trying osa-imessage

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

wtfaremyinitials commented 6 years ago

Okay, now try osa-imessage

svenyonson commented 6 years ago

Same error.

I literally copied the osa-imessage project folder (repo), ran npm install, then added a script called test.js.

then I execute: node test.js

$ cat test.js const imessage = require('osa-imessage');

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

$ node test.js (node:23350) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Command failed: /usr/bin/osascript -l JavaScript 445:509: execution error: Error on line 19: Error: no thread with handle '+3035206372' (-2700)

(node:23350) [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.

On Dec 25, 2017, at 2:52 PM, Will Franzen notifications@github.com wrote:

Okay, now try osa-imessage

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wtfaremyinitials/osa-imessage/issues/20#issuecomment-353888143, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWlLlbpwljEiIaOmGcL69GE0uh-wr6Hks5tD_zjgaJpZM4RGYBE.

wtfaremyinitials commented 6 years ago

Try including the country code on the phone number. (+1303520****)

svenyonson commented 6 years ago

That worked!

Thanks a bunch for your time and effort.

On Dec 25, 2017, at 3:03 PM, Steve Johnson steve@svenyonson.com wrote:

Same error.

I literally copied the osa-imessage project folder (repo), ran npm install, then added a script called test.js.

then I execute: node test.js

$ cat test.js const imessage = require('osa-imessage');

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

$ node test.js (node:23350) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Command failed: /usr/bin/osascript -l JavaScript 445:509: execution error: Error on line 19: Error: no thread with handle '+3035206372' (-2700)

(node:23350) [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.

On Dec 25, 2017, at 2:52 PM, Will Franzen <notifications@github.com mailto:notifications@github.com> wrote:

Okay, now try osa-imessage

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wtfaremyinitials/osa-imessage/issues/20#issuecomment-353888143, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWlLlbpwljEiIaOmGcL69GE0uh-wr6Hks5tD_zjgaJpZM4RGYBE.

wtfaremyinitials commented 6 years ago

Happy to help. Cheers

enzotrompeneers commented 6 years ago

I can only send a message when I interacted with the phone number before by Imessage mac/iphone. It doesn't send if there is no chat active with that person. Any ideas on that?