I’ve been using Twitter SDK with Javascript(jQuery) on a desktop browser, and everything works great. I get the response from the window,and it closes the window by itself no problem. However in a mobile browser, on the same page, it opens the window, I post the tweet, but it doesn’t trigger the response in my code, and the window doesn’t get closed by itself(with no close button either), though it doesn’t matter as much - the main problem is how to trigger that response.
Here’s some code for how I use the API, and where I handle the response:
//On page load
$(document).ready(function(){
//Load Twitter API
window.twttr = (function(d,s,id){
var t, js, fjs = d.getElementsByTagName(s)[0];
if(d.getElementById(id)) return; js=d.createElement(s); js.id=id;
js.src="https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) }});
}(document, "script", "twitter-wjs"));
//On ready, register the callback, and bind the event
twttr.ready(function(twttr){
twttr.events.bind("tweet", function(event){
alert("Successful!");
});
});
});
//Twitter button in html file:
<a href="https://twitter.com/intent/tweet?status=test" target="_blank">TWEET</a>
Is it an incorrect way of doing it, or are there any conflicts in a mobile version?
Any feedback would be appreciated.
Thanks