Skip to content

Instantly share code, notes, and snippets.

@bertrand-lupart
Created September 30, 2022 09:30
Show Gist options
  • Save bertrand-lupart/68641ca0f050dadaecfc3d948eb824c6 to your computer and use it in GitHub Desktop.
Save bertrand-lupart/68641ca0f050dadaecfc3d948eb824c6 to your computer and use it in GitHub Desktop.
AppleScript to send a SMS from a Mac using Handoff / Continuity
-- This script allows to programmatically send a SMS from a Mac using an iPhone carrier plan
-- Requirements :
-- * iPhone running iOS 8.1+ with a proper carrier plan
-- * Mac running macOS 10.10+
-- * Message forwarding should be properly configured on both devices. See
-- https://support.apple.com/en-gb/HT208386
-- Usage :
-- This script should be invoqued via Terminal with the osascript command :
-- osascript send-text.scpt 0123456789 "What's your name, James ?"
on run argv
set num to (item 1 of argv)
set msg to (item 2 of argv)
tell application "Messages"
set targetService to 1st account whose service type = SMS
set num to participant num of targetService
send msg to num
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment