I've found solutions that make it so that when you click a button on a website, it links to a phone number and the users phone will open up the dialer with that number pre-filled like so.
What I want to do instead is open up the users sms application in "compose message" mode to that specific number. Is there any way to do this? I've tried the following approach, but it doesn't work on Android:
sms://1-516-400-6217
There's just one easy step to follow. To include a link in any text message, just type or paste the full URL into your text. Most messaging platforms will automatically turn the URL into a link that allows contacts to click and access the linked page.
The general format is:
<a href="sms:+919999999999?body=Hello World!">Link</a>
You could also add multiple numbers to the recipient list:<a href="sms:+919999999999,+919999999990?body=Hello World!">Link</a>
I found this to be working on my Android device, as well:<a href="sms://+919999999999?body=Hello%20World!">Single recipient and encoded body</a>
A Small Demo:
body {
font-family: monospace;
text-align: center;
}
a {
font-size: 24px;
}
code {
font-size: 18px;
line-height: 26px;
white-space: normal;
word-break: break-word;
background-color: lightgray;
padding: 5px;
border-radius: 4px;
}
h1 {
margin-bottom: 5%;
}
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1> Run this Snippet on an actual mobile device to check if it supports the special links</h1>
<hr>
<pre><code><a href="sms:+919999999999?body=Hello World!">Single recipient and plain body</a></code></pre>
<a href="sms:+919999999999?body=Hello World!">Single recipient and plain body</a>
<pre>
<br>
</pre>
<pre><code><a href="sms:+919999999999,+919999999990?body=Hello World!">Multile recipient and plain body</a></code></pre>
<a href="sms:+919999999999,+919999999990?body=Hello World!">Multile recipient and plain body</a>
<pre>
<br>
</pre>
<pre><code><a href="sms://+919999999999?body=Hello%20World!">Single recipient and encoded body</a></code></pre>
<a href="sms://+919999999999?body=Hello%20World!">Single recipient and encoded body</a>
</body>
Source: Send a SMS Text From A Link
As mentioned in the article the support depends on the platform and the SMS app, some work while others don't.
Also avoid using it if there's no dynamic component involve for device detection; since on desktop older Operating Systems the link will do absolutely nothing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With