New “ShareLinkTask” API in Mango makes sharing links a two-line process

image
The old way of sharing links was cumbersome, time-consuming to implement and not robust, and only worked for one network.

András, the developer of SurfCube, has written about a new feature in the Windows Phone 7 Mango API which promises to save developers a huge amount of time and make their applications much more robust.

In the NoDo version of SurfCube a user is able to share links via twitter.  To code this feature however András had to do quite a bit of work.

He writes:

As you can imagine, it took a considerable effort to build this feature. We had to write code the communication with the bit.ly API, build two panels (authentication and tweet editing), create animations and had to handle tons of error conditions. We used Tweetsharp for accessing the Twitter API, but even for just sending a tweet, we had to learn a lot about TweetSharp, and integrate it into our app. In a later version of SurfCube, we took TweetSharp’s source code and manually eliminated the parts that weren’t about tweet sending to make the dll smaller and thus faster to load.

Windows Phone Mango however has a new API which makes sharing as simple as using two lines of code.

Mango (the OS itself) is integrated with Twitter, LinkedIn and Facebook. This means that most users who care about one or more of these networks can have his or her credentials entered into the OS. What is even better is that third party applications, like SurfCube can take advantage of this integration! There is just one, very simple API for all this: theShareLinkTask class.

The hundreds of code lines and all the XAML we had just got reduced to these two statements lines in SurfCube 4:

As a bonus, now we have the ability to share via Facebook, LinkedIn and Twitter. We can remove the dependency to the TweetSharp library (and its Hammock and Json dependencies), the twitter credentials UI, the twitter editing UI. And the “Share via Twitter” context menu can now be changed to “Share”.

And once you tap on “Share”, it is the responsibility of the OS to take care of all social networks, errors, url shortening and so on. Even though I prefer the tweet editing UI in SurfCube 3, the added benefit of LinkedIn, Facebook, smaller xap size and faster app startup (not to mention not having to worry about API changes) makes this change a no-brainer.

Windows Phone 7 Mango includes 1500 new APIs for developers, and this particular one will help the OS to maintain its reputation as the most social of operating systems, making it a no-brainer for any application to implement link sharing across a wide variety of social networks.

Read more at Doneteers here.

Comments