27

I was wanting to know if Android had a similar feature to the iPhone in that you can use an HTML A tag to send an SMS by setting the HREF attribute to the phone number you want to send the message to and prefixing it with "SMS:", i.e. href="SMS:02313213"

I've had a look around and can't seem to find anything that suggests it is available on Android.

Nemus
  • 3,405
  • 11
  • 32
  • 46
dakine
  • 431
  • 2
  • 5
  • 15

8 Answers8

30

I found the following which may help you:

http://tools.ietf.org/html/rfc5724

You can check sub-section 2.5 or 2.6 of this RFC to give you some additional pointers on formulating a proper SMS URL.

Eg. using formal URI-spec as detailed in sub-section 2.2 of rfc5724:

<a href="sms:+19725551212?body=hello%20there">SMS Me</a>  

Notice the 'escaped' character for the 'space' in the example above.

Hopefully the Android browser will permit you to generate XHTML forms based on this syntax. I believe they will (if I have some time over the next day, I shall give it a try on my Galaxy S).

gto406
  • 439
  • 3
  • 6
  • Hyphens are allowed as well, for visual aid only. – Steven Vachon Feb 13 '15 at 23:47
  • 1
    I've been messing-around with this type of URL in actual SMS messages (meaning, sending `sms:number?body=foo` to an SMS recipient. Currently (Sept 2020), Android converts the phone number into a dial-number tap-able link while iOS converts the whole thing into a message-this-number-including-body tap-able link. So it seems that iOS is currently a little more SMS-URL-friendly than Android, at least outside of a web context. – Christopher Schultz Sep 01 '20 at 20:26
  • Per the specification (rfc5724, sub-section 2.2) sms-recipients defined per RFC3966 - https://tools.ietf.org/html/rfc3966. – gto406 Jan 03 '21 at 18:19
5

href="sms:+xxx" works on my stock HTC Desire Android 2.2 browser and the Sense SMS app, but sms:+xxx?body= doesn't - error: invalid recipient(s). I was only really interested in setting the body - anyone seen / solved this problem?

My test page is here: http://jsbin.com/itama4/15

Ian Grainger
  • 4,329
  • 2
  • 40
  • 64
  • I am getting the same behavior, I think the issue is with how the sence app is working. On my phone (2.3.7 HTC EVO [Sense UI removed]), it works and opens up correctly in the Messaging app, but when doing it with a phone that has the Sense UI it gives an error and only works without body content. – Ray Apr 09 '12 at 17:14
  • I now have a Galaxy S2 with CyanogenMod 9 (default ICS SMS app) this does work for me - so I agree with you @Raymond. – Ian Grainger Apr 10 '12 at 08:14
  • Delayed response (my apologies) - the adoption of standards (like RFCs) are often in the 'eye of the implementer' so to speak. Each implementing vendor chooses how they wish to interpret a spec or RFC.This is where interoperability testing sessions - e.g. IOP test-fests that Open Mobile Alliance (now OMA Specworks) have promoted for many years (https://omaspecworks.org/about/) and only recently surfaced by IETF based on QUIC (https://www.ietf.org/blog/quic-automated-interop-testing/) are so useful. – gto406 Jan 03 '21 at 17:48
4

That should work:

<a href="sms:+437722735932">contact</a>
Josef Pfleger
  • 72,585
  • 15
  • 95
  • 99
2

I have noticed if you use a qrc code with text for mms:<phone_number>?body=<your message here.> this seem to work and avoid the error: invalid recipient(s)

here is a test qrc http://qrcode.kaywa.com/img.php?s=8&d=mms%3A555-555-5555%3Fbody%3DYour%20Message

EdChum
  • 294,303
  • 173
  • 671
  • 486
Andrew
  • 21
  • 1
1

If multiple recipients needed, this works:

Android:

sms:+15558675309,+15558675301?body=Text%20Here%20end!

iOS, macOS:

sms://open?addresses=+15558675309,+15558675301/&body=Text%20Here%20end!
Bobík
  • 1,345
  • 15
  • 15
1

If you wants to allow in Android and IOS, Following trick worked for me in both devices.

Without adding number :

sms:?&body<Your message goes here>
Harsh Sanghani
  • 1,626
  • 1
  • 10
  • 31
1

If you need a URL working for both Android and iOS you can do this trick:

sms:+123456789?&body=hello%20there
arcin91
  • 11
  • 1
0

You could use a CSS trick to display one or the other: CSS media query to target only iOS devices

@supports (-webkit-touch-callout:none) {
  /* CSS specific to iOS devices */ 
  .android { display:none }
  }

@supports not (-webkit-touch-callout:none) {
  /* CSS for other than iOS devices */
  .ios { display:none }
  }

<a class="ios" href="sms://+12345">SMS me</a>
<a class="android" href="sms:+12345">SMS me</a>
Leo
  • 2,274
  • 2
  • 17
  • 16