With the launch of iMessage on the Mac earlier this month, we now have what I think to be the perfect IM solution – cross device (not platform, sadly) syncing of message histories – why couldn’t anyone do this earlier?
You may like to add an iMessage Me link to your website/blog to make it easier for people visiting your page from a Mac or iOS device (iPhone, iPad, iPod touch) – just a tap and they’re all set to iMessage you.
For whatever reason, iOS and OS X use different URL schemes for iMessage – I understand why Messages for Mac may not want to adopt the sms: scheme, but I find it odd that iOS doesn’t like the imessage: scheme. So we’re left with two different schemes depending on the platform your visitor is using.
Using some fancy PHP trickery, here’s some code that will detect your visitor’s operating system, and based on that display either a sms: link or an imessage: one.
<?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; ?>
Throw this inbetween your standard link and you’re good to go.
<a href="PHPCODEGOESHERE:[email protected]">iMessage me!</a>
Or, put together:
<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 protected]">iMessage me!</a>
have you thought about making a full html code for this, php for some reason won’t work with a dropbox public site. could you possibly write a code for me that does
<a href=":[email protected]”>
Unfortunately PHP is used here to detect whether the user is on a Mac or iOS device, and then change the URL to suit.
You can use a href=sms:[email protected] or a href=imessage:[email protected] but remember that the SMS link only works on iOS, and the iMessage link only works on the Mac; it’ll throw up an error on iOS.
Have you tried renaming your .html file to .php? That worked for me on my own site.
Thanks for the solution, Giles. 🙂
That’ll work if your host supports PHP – sadly Dropbox doesn’t.
Is it possible that it activate a message and send to us?
E.g. When a user directly click on the link, it will send us notification automatic on clicking and we can start the conversation. Probably with a custom message. Possible?