Start an iMessage Conversation From the Web with Custom Links
By using a custom URL inside of an anchor tag, you can place a link on any website that will initiate a new iMessage conversation. Anyone clicking the link will then launch the Messages app in iOS or iMessages in Mac OS X to begin a new conversation with the specified Apple ID.
Even if you have limited knowledge of HTML the link structure is easy to use, here’s the format you’d want to use for Mac and iOS;
Mac OS X: imessage://email@example.com
<a href="imessage://firstname.lastname@example.org">Send iMessage to a Mac</a>
<a href="sms://email@example.com">Send iMessage to iOS</a>
Replace “firstname.lastname@example.org” with your own Apple ID that is configured to use with iMessage. Note that the iOS link uses “sms” as the identifier, meaning some users may send you an actual text message rather than iMessage if they are not set up to use Apple’s messaging protocol.
Because iOS and OS X use different URL schemes, you’ll need to use two different links by default. This could have advantages, if you only wanted people from iOS to reach you for example, but if you don’t like that idea there’s a nice workaround to the dual links by using the short PHP script offered by Beuagil.es. This script will detect the user agent and determine which link to use based on that, effectively combining the two iMessage links into one intelligent link:
<a href="<?php $useragent = $_SERVER['HTTP_USER_AGENT']; if(preg_match('/Macintosh/',$useragent)) $os = 'imessage'; elseif(preg_match('/iPhone/',$useragent)) $os = 'sms'; else $os = 'sms'; echo $os; ?>:email@example.com">Send an iMessage</a>
Obviously you’ll need a PHP capable website for the above script to work, otherwise you’ll have to use the HTML snippets offered at the top of the post.
You can also use similar URLs to initiate FaceTime calls from the web.