Open apps from browser in Windows Phone

Windows Phone is a solid operating system and has its unique features but its the developers, who let the OS down for some pressure or propaganda.

When I was using Android, if I click on a Twitter link in browser it automatically launches the Twitter app but that is not available in Windows Phone Twitter app, both apps are from Twitter Inc, but Twitter it does not treat Windows Phone users well. They can simply implement a URI scheme for posting tweets, send DM, show mentions and kind of things. Currently they have the URI scheme to open the app, but that’s not enough. For iOS users they have done everything.

If Twitter continue like this, Windows Phone community and developers should come with a Twitter client like Tweetie for iOS that has URI schemes for all twitter actions. So other developers will use this to show twitter related action in their apps. Lion has its beauty when its in the Jungle but not in Zoo, like wise Twitter related actions should be shown in the official twitter app or in a twitter client but not in the browser.

Facebook app in Windows Phone is great, they have implemented URI schemes well and those can be used by anyone, but many web developers are not aware of those URI schemes. Though most app developers use the Facebook URI schemes well, still most websites, show Facebook related contents in a web broweser, this is OK for PCs but disaster for Smartphones, we have Facebook app installed in our device and authenticated, but why need to authenticate Facebook again in our smartphone browser.

For that, I have come with a solution, that is simply a JS file to do the things not in browser but in the related app. This will work only with Windows Phone and this will be a very useful one for the web developers who have more smartphone readers.

For sharing something from browser to Facebook, I have implemented this simple JS

function ShareToFB(someTextToShare) {
	if(navigator.userAgent.match(/Windows Phone/i))
	{
		var uri = "fb:post?text=";
		uri+=someTextToShare;
		return uri;
	}
	else
	{
		alert("sorry this will only work for Windows Phone");
	}
}

This function, first checks the user agent and if its Windows Phone, this called the related URI scheme to post to Facebook app in Windows Phone. Then I call this JS from the below HTML code

<a href="#" onclick="this.href=ShareToFB('Hello world')">Share Facebook the hello world</a>

like this I can use other URIs as well, that are documented here.

Here is a demo you can try here. Remember this will work for Windows Phone only.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s