I want to use the Twitter App to send a tweet from my web app, instead of using the twitter button when a twitter client is installed.
If I am on an iPhone or Mac with the Twitter App installed, this app opens when redirecting the web app to a "twitter://" url. (see http://handleopenurl.com/scheme/twitter)
But if I want to show the Twitter Button only where the Twitter App isn't installed, how do I check for this? Suppose I have this code. How should twitter_app_installed() be? Is there a way to check if window.location="twitter://...";
won't work?
<div class="twitter-button"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://google.com" data-text="Hello World">Tweet</a></div>
<div class="twitter-app-button"><a href="twitter://post?message=Hello%20World%20http://google.com">Tweet</a></div>
<script>
function twitter_app_installed() { /* check if window.location="twitter://"; works */}
$(document).ready(function() {
if (twitter_app_installed()) $('.twitter-app-button').show();
else $('.twitter-button').show();
});
</script>
Plus: is there a correct way of adding a URL to the twitter:// scheme?