jssocials icon indicating copy to clipboard operation
jssocials copied to clipboard

adding SMS support

Open masciugo opened this issue 8 years ago • 6 comments

I ran into a scenario where I need to share by SMS. Does anybody think it may be a desiderable feature?

http://thenewcode.com/856/Send-a-SMS-Text-From-A-Link

masciugo avatar Nov 07 '16 14:11 masciugo

Why not, it sounds interesting. The question: is it cross platform? Or it will require separate shares for iOS and Android?

tabalinas avatar Nov 07 '16 23:11 tabalinas

Hi, it not only needs separate shares for iOS and Android, but also for different iOS versions. So I think there are two ways to handle this:

  1. include in jsSocials the logic to 'read' the client OS and version and construct the link accordingly (https://github.com/smeeckaert/sms-link)
  2. include the generic one and use a script like https://github.com/smeeckaert/sms-link to do it for you

In my case (https://onlinecommunityhub.nl/joomla-extensions/jssocials) I can use option 2 and construct the buttons via the Mobile_Detect library that I have implemented (I need that to show / not show some buttons on different devices)

Option 2. I can deliver a PR for. Just say 'go' :)

Ruud68 avatar Jun 28 '17 07:06 Ruud68

any (other) thoughts on this?

Ruud68 avatar Jul 12 '17 07:07 Ruud68

I wouldn't go for mobile detection inside jssocials (at least for now). Using external lib would mean one more dependency. Do you think we could provide info on how to achieve this inside this issue and then put it in the docs, for instance? Something like:

To add sms support you need:

  • include external lib (the one you mentioned)
  • define a custom share like jsSocials.shares.sms = { ... }

tabalinas avatar Jul 16 '17 21:07 tabalinas

Hi, damn... don't get any updates via mail, totally missed this one :S

Another scenario is to add the following share (untested):

        sms: {
            label: "SMS",
            logo: "fa fa-comments-o",
            shareUrl: "sms:{delimiter}body={text} {url}",
            delimiter: "?",
            countUrl: "",
            shareIn: "top"
        },

This will work in 85% (+) of the devices. image

The user can then specify the param {delimiter} to ? to also have it working on iOS devices. How he detects what device is up to him. the code below is fairly simple and something like that can be used in the documentation.

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;

Ruud68 avatar Aug 29 '17 10:08 Ruud68

PR for this added here: https://github.com/tabalinas/jssocials/pull/166

Ruud68 avatar Sep 05 '17 14:09 Ruud68