Implemented SMS support

More
6 years 9 months ago #417 by Nikola Nikola
SMS support was created by Nikola Nikola
This is proposal for enhancement.
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 :)
Code:
sms:{label:"SMS",logo:"fa fa-comments-o",shareUrl:"sms:?&body={text} {url}",countUrl:"",shareIn:"self"}
Code:
sms: { label: "SMS", logo: "fa fa-comments-o", shareUrl: "sms:?&body={text} {url}", countUrl: "", shareIn: "self" },
I see there is topic on GitHub but last post was in November 2016.
Ofcourse Ruud will polish code etc. :)

PS: Example
The topic has been locked.
More
6 years 9 months ago - 6 years 9 months ago #418 by Ruud van Lent
Replied by Ruud van Lent on topic SMS support
Hi,

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:

Code:
sms:+33102030405?body=Body Content
This thing is, depending on which version of iOS you use, the ? separator must be changed to either a ; or a &.


In your proposed code I see you use:
Code:
sms:?&body={text} {url}

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 '//'
Last edit: 6 years 9 months ago by Ruud van Lent.
The topic has been locked.
More
6 years 9 months ago - 6 years 9 months ago #419 by Nikola Nikola
Replied by Nikola Nikola on topic SMS support
Hmm. I see that it's not that easy like seems to be.

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:

Code:
sms:?body=message

For iOS same thing except with the ;

Code:
sms:;body=message

Here's an example of the code I use to set up the SMS:

Code:
var ua = navigator.userAgent.toLowerCase(); var url; if (ua.indexOf("iphone") > -1 || ua.indexOf("ipad") > -1) url = "sms:;body=" + encodeURIComponent("I'm at " + mapUrl + " @ " + pos.Address); else url = "sms:?body=" + encodeURIComponent("I'm at " + mapUrl + " @ " + pos.Address); location.href = url;

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...

Last edit: 6 years 9 months ago by Nikola Nikola.
The topic has been locked.
More
6 years 9 months ago #423 by Ruud van Lent
Replied by Ruud van Lent on topic SMS support
Hi,

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...
The following user(s) said Thank You: Nikola Nikola
The topic has been locked.
More
6 years 9 months ago #424 by Nikola Nikola
Replied by Nikola Nikola on topic SMS support
I absolutely agree! :)
The topic has been locked.
More
6 years 6 months ago #468 by Ruud van Lent
Replied by Ruud van Lent on topic SMS support
The topic has been locked.
More
6 years 6 months ago - 6 years 6 months ago #500 by Ruud van Lent
Replied by Ruud van Lent on topic SMS support
Hi Nidzo,

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. :)
Last edit: 6 years 6 months ago by Ruud van Lent.
The topic has been locked.
More
6 years 6 months ago #510 by Nikola Nikola
Replied by Nikola Nikola on topic SMS support
Tested on Android for now.
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 :)
Attachments:
The topic has been locked.
More
6 years 6 months ago #512 by Ruud van Lent
Replied by Ruud van Lent on topic SMS support

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.
The topic has been locked.
More
6 years 6 months ago - 6 years 6 months ago #518 by Nikola Nikola
Replied by Nikola Nikola on topic SMS support
Tried right now and it's same with all third party applications except Textra. Only this application gives ? in recipient field and link with title in message field.
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.
Last edit: 6 years 6 months ago by Nikola Nikola.
The topic has been locked.