Archive for the ‘.Net’ Category

Integrating with Facebook on Windows Phone 7

March 18, 2011

I recently helped a collegue with Facebook integration on Windows Phone 7. The requirement was to log in and post a link to the users stream. I quickly came across the Facebook C# SDK found on codeplex at: http://facebooksdk.codeplex.com/. Unfortunately the otherwise pretty straight forward API is poorly documented, so it took me a bit of trial and error to get what I wanted. Here are the steps I took:

(more…)

DynamicJson and unit-testing JSON services

January 1, 2011

I’m currently messing with setting up unittests for a JSON/REST’ish service. My goal is having (or at least have a looke at having :)) a test suite that executes over HTTP in exatcly the same manner as an actual client. One advantages of this I think, will be the ability to execute the tests against a remote system, once the system is deployed.

Trying to figure out the best way to inspect the returned JSON data, I came across DynamicJson (http://dynamicjson.codeplex.com/). The library combines the new C# 4.0 dynamic features with a JSON parser to allow for what you see below:

[TestMethod]
public void GetList()
{
    var webClient = new WebClient();
    webClient.Encoding = UTF8Encoding.UTF8;
    webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json");

    var result = DynamicJson.Parse(webClient.DownloadString("http://localhost/WebSite/List/BE33A625-63F3-4014-85E7-D306F00A5A7E"));

    Assert.AreEqual("TestList", result.Title);
}

The library does contain a serializer as well, but it only support basic types (so GUID’s for instance are not supported). I find the JavaScriptSerializer much more usefull..

iOS Push Notifications in C# with apns-sharp

November 28, 2010

I just recently set up push notification in an iOS application for the first time. The back-end is implemented in C# and searching the web for existing solutions i came across “apns-sharp” (http://code.google.com/p/apns-sharp/). “apns” is short for Apple Push Notification Service and the library, as you would expect, provides a C# api for sending iOS push notifications. The library also contains an api for Apple’s Feedback service for – a service used to retrieve push tokens that are no longer valid, so as to be able to clean up subscribtions.

Initially i got things working on my dev setup without hardly any effort. I then proceeded to publish the project to by budget webhost http://www.web10.dk and suddenly I wasn’t receiving notifications anymore. It took me quite some time to figure out what was wrong…

(more…)