Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pre-populate the sms body text via an html link

How to use an html link to open the sms app with a pre-filled body?

Everything I have read seems to indicate that sms:18005555555?body=bodyTextHere

Should work, but on the iPhone, this doesn't work. If I take out the ?body=bodyTextHere, and just use sms:phonenumber, it works.

I have seen several instances where QR codes do this through a safari link. How are they able to pre-populate the body text?

like image 744
merlincam Avatar asked Jun 25 '11 20:06

merlincam


People also ask

Can you hyperlink SMS?

The short answer is, adding hyperlinks into SMS text messages isn't possible. Hyperlinks can only be used in emails and on your business website.

Can SMS display HTML?

SMS does not support HTML. Do not use href tags in the link address. For example, <a href="www.example.com">link text</a> is not supported.

How do you create a button that opens SMS compose to a phone number in HTML?

Approach: Using <a> href attribute: Enter the phone number in place of the URL and add sms: before it to make an SMS link. Add the text between the tags that will appear as the clickable link.

How do I create a hyperlink that sends an SMS message?

With a bit of HTML, it's possible to create a hyperlink that sends an SMS message. You can even prepopulate the SMS body text via the link! Here's how. Links need no introduction. They’re everywhere on the internet, literally. In HTML, links are defined with the <a> tag.

Did You Know you can launch the SMS app with HTML?

But few people know that you can launch the SMS app on your website visitors’ phones with an HTML link. This is perfect for starting conversations with your customers, especially when you consider that you can add a Click to Text link to more than just text. We’re confident you’ll love how easy it is to text your customers with SimpleTexting.

How do I add click to text to my website?

Add Click to Text to the following places, or anywhere you may include an HTML link: It only take a couple of minutes to create an HTML link that sends a text. And you can even pre-populate the SMS body text via the HTML link. Here’s how: 1. Write Your Link Text This is the text that your website visitors will read and click on.

Can I send custom SMS messages using simple HTML links?

While HTML anchor tags are most often used to link pages, there are also other possibilities including launching an email client and the Messages app on mobile devices. This article explores sending custom SMS messages using simple HTML links.


2 Answers

It turns out this is 100% possible, though a little hacky.

If you want it to work on Android you need to use this format:

<a href="sms:/* phone number here */?body=/* body text here */">Link</a>

If you want it to work on iOS, you need this:

<a href="sms:/* phone number here */;body=/* body text here */">Link</a>

Live demo here: http://bradorego.com/test/sms.html (note the "Phone and ?body" and "Phone and ;body" should autofill both the to: field and the body text. View the source for more info)

UPDATE:

Apparently iOS8 had to go and change things on us, so thanks to some of the other commenters/responders, there's a new style for iOS:

<a href="sms:/* phone number here */&body=/* body text here */">Link</a>

(phone number is optional)

like image 89
Brad Orego Avatar answered Sep 28 '22 04:09

Brad Orego


I know this is an old thread but stumbled upon it and found that some parts are no longer relevant.

I've found that if you want to just per-populate the text without adding a phone number, you can do the following:

sms:?&body=/* message body here */ 
like image 20
Ali Avatar answered Sep 28 '22 06:09

Ali