I am using the social sharing plugin for sharing messages and pictures from my mobile app to facebook and twitter,
The application will display a alert for "shared successfully" if the sharing is success and will display "sharing cancelled" if the plugin displays any error message.
For facebook it works like a charm, but in twitter there is a problem.It works fine for all scenarios except Duplicate tweets(person sharing the same tweet more than once) both the alerts are triggered as all the conditions of the plugin satisfies(internet connection, user authentication, valid message) but the twitter app in phone throws the "duplicate tweets" error late. Anyone here please help me to find that error message before triggering the alerts.
function shareViaTwitter(id, message, image, url) {
canShareViaTwitter();
message = message.replace(/<br *\/?>/gi,'\n');
var successmessage = window.localStorage.getItem('canshareTwitsuccess');
var errormessage = window.localStorage.getItem('canshareTwiterror');
if(errormessage != '' && errormessage != 'null' && errormessage != null)
{
navigator.app.loadUrl('https://play.google.com/store/apps/details?id=com.twitter.android&hl=en', { openExternal:true });
reloadPage();
}
else
{
if(navigator.onLine) {
var isAndroid = /android/i.test(navigator.userAgent.toLowerCase());
if(isAndroid) {
message = (message) ? message : null;
image = (image) ? image : null;
url = (url) ? url : null;
window.plugins.socialsharing.shareViaTwitter(message, image, url, function(msg){}, function(msg){});
$("#sharingText").html("Shared Successfully");
$('#sharing-sucess-trigger').trigger('click');
}
} else {
$("#sharingText").html("Shared Failed! \nNo Network Connection");
$('#sharing-sucess-trigger').trigger('click');
}
reloadPage();
}
}
function canShareViaFacebook()
{
//alert("canshare")
window.plugins.socialsharing.canShareVia('com.facebook.katana', 'msg', null, null, null, function(fbsuccess){window.localStorage.setItem("canshareFbsuccess", fbsuccess);}, function(fberror){window.localStorage.setItem("canshareFberror", fberror);});
}
function canShareViaTwitter()
{
//alert("canshare")
window.plugins.socialsharing.canShareVia('twitter', 'msg', null, null, null, function(twitsuccess){window.localStorage.setItem("canshareTwitsuccess", twitsuccess);}, function(twiterror){window.localStorage.setItem("canshareTwiterror", twiterror);});
}