Created
July 21, 2015 18:52
-
-
Save alekhinen/9b4c3e101c9d4419b9d0 to your computer and use it in GitHub Desktop.
Programmatically send an iMessage from Terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {targetBuddyPhone, targetMessage} | |
tell application "Messages" | |
set targetService to 1st service whose service type = iMessage | |
set targetBuddy to buddy targetBuddyPhone of targetService | |
send targetMessage to targetBuddy | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This sends an iMessage to a buddy. Note: If the number you specify isn't in your buddy list, then the command will fail. For security reasons, Apple does not allow you to programmatically start a conversation with a new buddy. However, there is a workaround for this - see https://gist.github.com/alekhinen/b3a112cfbb5cad70e6e2. It's a bit kludgy as it opens up the Messages app and goes through the UI to send a new message, but it works.