jssocials
jssocials copied to clipboard
adding SMS support
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
Why not, it sounds interesting. The question: is it cross platform? Or it will require separate shares for iOS and Android?
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:
- include in jsSocials the logic to 'read' the client OS and version and construct the link accordingly (https://github.com/smeeckaert/sms-link)
- 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' :)
any (other) thoughts on this?
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 = { ... }
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.
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;
PR for this added here: https://github.com/tabalinas/jssocials/pull/166