The LiveSDKHelper Portable Library helps you "Live'n" up your apps...
- Posted: Jul 08, 2013 at 6:00AM
- 15,988 views
Today's project is one by a Friend of Channel 9, Scott Lovegrove. Microsoft's Live SDK is the primary means with which you can connect your programs or apps to the Live services. SkyDrive, Outlook.com (and Skype too).
Cloud documents, photos, calendars, messaging, contacts, friends and more are all available for you to integrate into your app's via the Live SDK.
Scott's taken the Live SDK and created a portable library that helps you ingrate it even faster and easier!
A while back I was working on a project that allowed me to actually look at, and use, the Live SDK in order to access information on SkyDrive. I was surprised to find just how hard it was to use the Live SDK, so as part of building the main project, I also built a little helper for using the Live SDK.
So what is the LiveSDKHelper? Well basically, it’s a collection of classes, enums and strings that just take the chore out of using the Live SDK. It’s a portable class library that works with both Windows Phone (7.5 and 8) and Windows 8. But you probably assumed that, right!
Onto some code! In Windows Phone, as part of the Live SDK, we are given a signin button control that we can use to enable our end users to sign into their Microsoft Account. This button requires you to give it some scopes so the user knows exactly what information your app wants to access. This is the first part of the helper:
//wl.basic wl.signin wl.offline_access wl.skydrive_update wl.calendars
var scopes = new List
SignInButton.Scopes = scopes.ToConcatenatedString(
scope => scope.ToStringScope(),
So no more remembering what each scope’s string was.
Within the library are a number of constants for you to use in order to access certain parts of the Live SDK, like your Skydrive root folder, or your photos folder, or to get your friends. For example:
var result = await _client.GetAsync(MeDetails.MyFriends);
This makes it really easy to make sure you’re putting the right strings into the client calls.
But what about the responses? Some of the posts I’ve seen create dynamic objects based on the results, but what if you want something a bit more concrete? Well in all the responses back from the client is a property called RawResult, which is basically a JSON object that can be deserialized with your favourite deserializer. What my library gives you is a set of concrete classes that you can use in order to deserialize those results. Again, some code:
Again, this just makes it so much easier to deal with. And there’s plenty more to explore. At the moment, the library covers SkyDrive, Calenders and contacts.
If you want to give it a go, it’s installable from nuget.
[GD: I cribbed 99% of Scott's post, with his permission... ]
Grabbing the latest drop from github, it complied and ran with no problems, the very first time (you know how much I love that). Here's a snap of the Solution;
Let's focus on the meat, the LiveSDKHelper. One thing I like was the references/dependences (or lack thereof).
That minimal dependency list should make the Helper much easier to us across all your projects, from both a coding and a licensing concern.
Here are some snaps of the Playground app running;
(Yeah, that's a little sad... um... yeah...
One area that caught my eye was the SkyDriveHelper and folder;
There's just something about building SkyDrive integration into my app's that I dig. I've been wanting to do it for years. Now it's not only possible, but highly encouraged and supported!
Want to see in action? Then check out Scott's Store Card Buddy app.
Here's a snap of it running on my system;
And a snip of code;
While you might not need Scott's LiveSDKHelper, it's likely that if you are going to be using the Live SDK you're already written something like it, so why write it yourself when Scott's already done some of the dirty work?