Implemented SMS support
- Nikola Nikola
- Topic Author
- Offline
- Posts: 26
- Thank you received: 3
I saw on some sites social plugin that have possibility to share article via SMS message. I dig it into source code and found that sms: url triggers Messaging applications on smart phones. I added that code in jsSocials plugin and tested on Android and iPhone and it works as expected
Ofcourse Ruud will polish code etc.
PS: Example
- Ruud van Lent
- Offline
- Posts: 1464
- Thank you received: 100
thanks for the code!
Did some research and run into the following:
In the world of SMS URLs, iOS is making our life hard.
The standard way to write an SMS link in HTML is this one:This thing is, depending on which version of iOS you use, the ? separator must be changed to either a ; or a &.Code:sms:+33102030405?body=Body Content
In your proposed code I see you use:
So that makes me wonder why the additional & before body, and if this will work in all iOS versions?
Do you have a reference on why this is the correct way?
I also see in your example (on android) that when clicking the button, the text and link to the page is correctly added to the sms text, but it prefills the phone number to send the sms to with '//'
- Nikola Nikola
- Topic Author
- Offline
- Posts: 26
- Thank you received: 3
I tested on Huawei and Sony device with Android 6 and 5.1 and iPhone 6 with iOS 10.
In native messaging application on all three devices, field for recipient is blank and all you need to do is add recipient number.
In some third party applications such is Textra on Android recipient field is filled with ? . In that case from recepient field it must be deleted ? as recepient and added correct one.
Yes there are some catches and not so simple I must admit.
I found that site I saw plugin in action uses e-mailit share plugin.
Further tests should be carried out.
EDIT: Found this
I suspect in most applications you won't know who to text, so you only want to fill the text body, not the number. That works as you'd expect by just leaving out the number - here's what the URLs look like in that case:
For iOS same thing except with the ;
Here's an example of the code I use to set up the SMS:
and that also works for all the devices mentioned above.
It's pretty cool that URL schemes exist to access device functionality and the SMS one will come in pretty handy for a number of things. Now if only all of the URI schemes were a bit more consistent (damn you Apple!) across devices...
- Ruud van Lent
- Offline
- Posts: 1464
- Thank you received: 100
here we go: github.com/tabalinas/jssocials/issues/11...suecomment-311583362
for me it is important to have sms support incorporated in the jssocials script. I do not wan to maintain a fork
So lets see if we can have a go over there...
- Nikola Nikola
- Topic Author
- Offline
- Posts: 26
- Thank you received: 3
- Ruud van Lent
- Offline
- Posts: 1464
- Thank you received: 100
- Ruud van Lent
- Offline
- Posts: 1464
- Thank you received: 100
can you test the SMS button on this url: office.onlinecommunityhub.nl/ll_test/org...or-tijd-te-genereren
It always shows (also on desktop).
When using Android the link should start with: sms:?
When using iOS (<= version 8 ) the link should start with: sms:;
When using iOS (> version 8 ) the link should start with: sms:&
If tests are okay, can you then also comment on github ( github.com/tabalinas/jssocials/pull/166) that the PR works as expected etc. :)
- Nikola Nikola
- Topic Author
- Offline
- Posts: 26
- Thank you received: 3
Android Messages by Google parse code correctly.
Native SMS messaging application also parse code correctly but problem is with third party applications such as Textra, Chomp SMS, YAATA, GO SMS Pro, Pulse (these are popular SMS applications on Google Play Store so I tested them). These apps put sharing code in recipient field and message field is blank.
Today I will test on iPhone 6 device with iOS 10
- Ruud van Lent
- Offline
- Posts: 1464
- Thank you received: 100
Nidzo wrote: Native SMS messaging application also parse code correctly but problem is with third party applications such as Textra, Chomp SMS, YAATA, GO SMS Pro, Pulse (these are popular SMS applications on Google Play Store so I tested them). These apps put sharing code in recipient field and message field is blank.
Hi Nidzo, Thanks for the extended testing!
I can only detect mobile (yes / no), OS (iOS, android), OS Version. With these variables I construct the 'delimiter' > iOS does not comply to the standard and even differentiates between versions lower then 8 and higher then 8.
The logic for this is in the jssocials plugin.
Because the webpage (and the buttons) are generated by the browser on the device, we have no knowledge about which app is installed and how they handle the SMS: url.
So I do not think I can 'fix' that (I also think it isn't broken?)
I do not use these apps my self, no idea why they do not work with the default url.
Have you tried one of these apps on the website where you originally got the SMS sharing url from? Just curious if it works on that site.
- Nikola Nikola
- Topic Author
- Offline
- Posts: 26
- Thank you received: 3
The only difference in code is that they use sms:?&body= and your link starts with sms:%3Fbody=
I will test on iOS 10 latter and leave feedback here.