Plugin to open phone's SMS app

I have seen my question several times on various forums, on how to open the device’s default Text app.
Every time someone asks this, they get replied with a phoneGap plugin on how to have the app they are building, send a text string to a phone number. They never read the question.
I need to open the phone’s existing SMS/MMS app. I want to pass to it a text string (message to send via sms). I do not want to pass to it, a telephone number.
The reason I want to open the phone’s existing SMS app is so that my user can select his own contact to send the message to.
I know my end user will be happy looking up a contact name from their list rather than typing into my app a memorized telephone number.

It also works with tel = “”

Function sms(tel, body)
  If InStr(navigator.appVersion, "iPhone") Then
    location.href="sms:" & tel & "&body=" & encodeURIComponent(body)
  Else
    location.href="sms:" & tel & "?body=" & encodeURIComponent(body)
  End If
End Function

Check out the EmailSkypePhoneSMS sample.

Alexander, thank you! Don’t I have to place something into my config.xml?

amagg
April 14 |

It also works with tel = “”

Function sms(tel, body)
If InStr(navigator.appVersion, “iPhone”) Then
location.href=“sms:” & tel & “&body=” & encodeURIComponent(body)
Else
location.href=“sms:” & tel & “?body=” & encodeURIComponent(body)
End If
End Function

This solution does not depend on PhoneGap.

Does this solution directly send the SMS or does it take the user to their Message app on their phone? Like to avoid the second if possible.

You can no longer send background sms messages… too many bad actors were hijacking users accounts and wreaking havoc.

Yes, it takes you to the Messages app.

You could use an SMS service like AWS offers. That would avoid the messaging app. I believe the first 100 sms msgs a month are free. My bill seems to indicate they average 0.6 cents each - but I haven’t paid for any yet, and have sent more than the bill suggests I can for free.