Home » Android » javascript – sms: link with alphabetical parameters interpreted as numbers on Samsung Galaxy S7

javascript – sms: link with alphabetical parameters interpreted as numbers on Samsung Galaxy S7

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a link on my website to open up a text with a new message. The following link works on most Android phones:

sms:5555555555?body=JOIN

But on the Galaxy S7, the ?body=JOIN parameter is interpreted to be a part of the phone number itself, as if the letters we input on a keypad. So the example above, would open up a new message to the phone number: 555555555526395646 and an empty message body.

I don’t have an s7 myself so it’s difficult to debug. Any ideas what else I can try to make it work as expected on the s7?

How to&Answers:

Different platform wise it will work differently. check challenges section on this link

For iOS same problem here and for android its partially support

Answer:

As Rajesh suggests, this will widely differ for different platforms, and sometimes for different version. This is the structure you would use for Android :

<a href="sms:/* Phone Number */?body=/* Body of the message */">Link</a>

And for iOS :

<a href="sms:/* Phone Number */&body=/* Body of the message */">Link</a>

Keep in mind that these formats can change (in your example the format works on most Android devices, but not on an S7; in other examples, the format was different for sending SMS in iOS 7 and iOS 8). Also, note that the app which handles the SMS URI can be changed on Android, and manufacturers take advantage of it (which may be what caused the malfunction on the S7 in the first place). So tweaking with exceptions can be a little hacky.

Otherwise, you could consider using an existing package like sms or a service like Twilio.

Answer:

Although I cannot reproduce the behaviour, here are some links from the RFC’s addressing the sms: and tel: URI schemes.

Under section 2.2 of RFC 5724 – URI Scheme for GSM Short Message Service is the formal definition of the URI, which says that the sms-recipient (the phone number you want to send the sms to) must be equal to telephone-subscriber which is defined in RFC 3966.

Although, your URI seems to work correctly on most of the devices (quirk? edge-case?), you must cross-check the format with the one described in the RFC to be sure that it’s standards-compliant. Or maybe it’s possible that it’s a software/parser bug on the device itself! (not sure though…)