Autocomplete SMS message in Phonegap / Cordova iOS and Android
Is there a way to send SMS automatically using Phonegap or Cordova on iOS and Android? Unless there is a way to pre-fill a text message in the native app for the user to confirm the sent message in the same way?
Just add to KateMihalikova's answer (I don't have enough comments to add a comment), but her answer is correct except for iOS> = 7; IOS 7 body is not supported (I believe if you already had a history with the SMS number in question this will work, but I haven't tested it); however iOS 8 brought back body preprocessing: you must replace ; which was used for iOS <= 6 with & instead of:
iOS 8: sms:+123456789&body=hello there
sms:
schema
Android: sms:+123456789?body=hello there
iOS! = 7: sms:+123456789;body=hello there
iOS = 7: sms:+123456789
- body not supported
You can use link or javascript location
:
<a href="sms:+123456789?body=hello there">Send SMS</a>
window.location = "sms:+123456789?body=" + encodeURIComponent("hello there");
The sms app opens by default and populates with the provided data.
Cordova plugin
Some examples:
- https://github.com/hazems/cordova-sms-plugin
- https://github.com/aharris88/phonegap-sms-plugin
Not tested
9.3.2015 modified with iOS 8
I can confirm that with ios7, body text will work as long as the associated number has an existing chat history.