Trying to send SMS in iOS 10, is the sms: protocol violated?

I have a click-to-send-sms button.

Now I use this code when I click the button:

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 tell me that it no longer works in iOS 10, nothing happens when a button is pressed. (the problem is not UA recognition, it goes into "& body = ...")

I don't currently have an ios 10 device for debugging ... have they changed the way I open sending SMS messages? Maybe I need to use the encodeURI component for the body, for example, android / window?

+4
source share
1 answer

No, it seems. Just tested it 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>

, "" .

, . URI ( %20 , ). body encodeURIComponent.


, , , Apple :

sms Messages. URL- - "sms:", - , SMS-. 0 9 (+), (-) (.). URL .

body, , .

iOS < 7 <a href="sms:0412345678;body=text">send sms</a>
iOS > 7 <a href="sms:0412345678&body=text">send sms</a>

, <a href="sms:0412345678&body=test">send sms</a> :

  • iPhone 6+ (iOS 10.0.1)
  • iPhone 6 (iOS 10)
  • iPhone 5 (iOS 9)
  • iPhone 4S (iOS 8)
+5

Source: https://habr.com/ru/post/1654793/


All Articles