I have a click-to-send-sms button.
Now I'm using this code when the button is clicked:
if (platform == 'iOS') {
if (version == 4 || version == 5 || version == 6 || version == 7) {
link = 'sms:' + serviceNumber + ';body=' + body;
} else {
link = 'sms:' + serviceNumber + '&body=' + body;
}
} else {
link = 'sms:' + serviceNumber + '?body=' + encodeURIComponent(body);
}
window.location.href = link;
They are telling me that it isn't working anymore in iOS 10, nothing happens when the button is clicked. (the problem is not in the UA recognition, it goes into the "&body=...")
Currently I don't have an ios 10 device to debug... did they change the way to open the SMS outbox? Maybe I have to use encodeURIcomponent for the body like android/windows?
It seems not. Just tested this on my iPhone 6+ running iOS 10.0.1
Both clicking the link and the button worked perfectly, opened up the Messages app with the correct number and added the text to the body.
Adding spaces, numbers and symbols works. Although standard URI components apply (adding
%20
adds a space for example). So I would recommend sanitising thebody
withencodeURIComponent
.From what I can tell it seems Apple hasn't even updated their documentation on this:
However, the
body
parameter is obviously working.iOS < 7
<a href="sms:0412345678;body=text">send sms</a>
iOS > 7
<a href="sms:0412345678&body=text">send sms</a>
After testing I've confirmed that
<a href="sms:0412345678&body=test">send sms</a>
works on: