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
It seems not. Just tested this on my iPhone 6+ running iOS 10.0.1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<a href="sms:0412345678&body=testing">send sms</a>
<button onclick="window.location.href = 'sms:0412345678&body=testing'">send sms</button>
</body>
</html>
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 the body
with encodeURIComponent
.
From what I can tell it seems Apple hasn't even updated their documentation on this:
The sms scheme is used to launch the Messages app. The format for URLs of this type is “sms:”, where is an optional parameter that specifies the target phone number of the SMS message. This parameter can contain the digits 0 through 9 and the plus (+), hyphen (-), and period (.) characters. The URL string must not include any message text or other information.
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: