Tag: ShareStatusTask

Windows Phone: Sharing Content

If you writing an app and want to add some social sharing capabilities like posting link to Facebook or twitter. Your initial approach may be to go to and check out each of their api’s or to go to codeplex and search for a C# api someone’s written that makes the integration simpler. But right from that start Windows Phone has had a much simpler way of doing things.

The ShareLinkTask provides a simple way to post messages to any social network the user has registered on their phone. You don’t need to do anything with authorising your app with facebook etc which not only makes things easier for you, but your users are also pleased as they don’t have to worry about what you may be doing with their passwords.

It also only takes 4 lines of code. Simply create an instance of the ShareLinkTask, set the tile and message and call the show function:

1ShareLinkTask shareLinkTask = new ShareLinkTask();
2shareLinkTask.LinkUri = new Uri("http://www.himynameistim.com");
3shareLinkTask.Message = "Check out this great blog";
4shareLinkTask.Show();

As well as the ShareLinkTask there is also a ShareStatusTask and ShareMediaTask that can be used if you just want to post a status update or post and image.

1ShareStatusTask shareStatusTask = new ShareStatusTask();
2shareStatusTask.Status = "I'm developing a Windows Phone application!";
3shareStatusTask.Show();
4
5ShareMediaTask shareMediaTask = new ShareMediaTask();
6shareMediaTask.FilePath = path;
7shareMediaTask.Show();

Social media isn’t the only way of sharing content on a phone though, there is also email and sms. Both of these are just as easy to do as social media though:

For email use the EmailComposeTask

1EmailComposeTask emailComposeTask = new EmailComposeTask();
2emailComposeTask.Subject = "Awesome website";
3emailComposeTask.Body = "Foo bla bla";
4emailComposeTask.Show();

And for SMS use the SmsComposeTask

1SmsComposeTask smsComposeTask = new SmsComposeTask();
2
3smsComposeTask.To = "2065550123";
4smsComposeTask.Body = "Try this new application. It's great!";
5
6smsComposeTask.Show();

For more information have a look at the MSDN documentation:

Share Link Task - http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394009(v=vs.105).aspx

Share Status Task - http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394027(v=vs.105).aspx

Share Media Task - http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207027(v=vs.105).aspx

Email Componse Task - http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394003(v=vs.105).aspx

SMS Compose Task - http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394005(v=vs.105).aspx