Plugin to open phone's SMS app


#1

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.


#2

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

#3

Check out the EmailSkypePhoneSMS sample.


#4

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

#5

This solution does not depend on PhoneGap.