Category Archives: Software Development

Tech : GMail EAS Changes

For longer than I can remember I have been a GMail user. Initially I was scared of it – putting all my mail on the web seemed like a crazy plan, but eventually I signed up and dropped by ISP’s email account for a GMail address. Ever since, I have happily enjoyed my email anywhere, labeling and archive, a host of free space and even piece of mind offered by two factor authentication. I have seen no reason whatsoever to doubt my decisions, until news broke  last night that Google were planning to drop EAS support for Individual GMail accounts (http://www.wpcentral.com/google-drops-exchange-activesync-what-s-it-mean-windows-phone).

Like many users, I choose my loyalty to products based on the best one available at the time. Typically this means that I use services or products from several companies at the same time, basing each decision on its merits not brand allegiance. Unfortunately I seem to have picked my poison in this war by buying into the Windows Phone mobile environment. My reasons are simple, I prefer the interface, speed and simplicity of the WP devices – I have no need for a  powerhouse uberhacker device in my pocket, I just like my phone to do what I need, when I need in the easiest way possible. I had an android phone, a symbian Nokia device , iPads and iPhones and this is where I have ended up, its just what I prefer – comparisons, features, reviews, and out and out hardware battles aside.

Inconveniently  for me it seems that my personal tastes have landed me right in the “EAS Switchoff” firing line. In a battle between ancient and bitter rivals, the true looser will not be a brand name, a sales figure or a jarring comment at a tech expo – its me, the customer. Standing to lose functionality on my Windows Phone device, because to Google , EAS is a “dead” technology.

I am sure Microsoft will update the Mail app to support whichever method becomes the next favorite, but for now I can’t help but look at other options for my email account, before the floor falls away under my feet – after all, I am not about to can an expensive phone, just to chase a feature rich email experience.

 

Hints : Accepting iCal Appts In Outlook When You Are The Organiser

A case I have been working on has highlighted to me just how little information there is about this rather useful knowlegebase article – so i decided I would quickly knock something up to make sure I can remember next time this little solution is needed.

If you have a centrally run system which spits out iCal files left right and centre, this might be right up your street. The issue occurs when you attempt to accept an appointment that you are listed as the organiser of. Assuming your system doesn’t automatically add the appointment to your calendar, you will be faced by two confliciting messages.

“As the meeting organizer, you do not need to respond to this meeting”

and

“This meeting could not be found in your calendar”

Up until Outlook 2007, as the organiser you would be able to accept the meeting – which would add it to your calendar, but now this is not possible – as OL 2007 and up attempt to prevent duplicate items with this handy message. The only issue being this stops your centrally generated iCal ever making it into your Caledar, and in turn messes up your ability to track responses.

The solution to this is a handy registry entry contained in the article : http://support.microsoft.com/kb/940403

This entry means that when you open up an iCal file – in which you are listed as the organiser, Outlook automatically adds the event to your caledar if its not already there. Allowing you the full benefits of having the meeting within Outlook, without having to create the iCal in Outlook/Exchange.

Useful Integration Tip !

Fingers crossed this helps someone out 🙂

Understanding : The Police API – The Perfect Introduction To API Programming (Part 1)

When I found myself gazing at the news during lunch the other day, my attention was suddenly caught by the announcement of an iPhone application which can tell you about the crime history of your current location.

Like any developer, as soon as I saw this my first response was “Wow, the police have an API”. And so they do, http://www.police.uk/api/docs/ . The police API is a RESTFul JSON Web service that uses HTTP GET requests to fetch JSON formatted data about a multitude of (historical) crime and police related information, this being said the data seems to only be about a month behind. The API is authenticated, using an API key you must apply for, and then BASIC HTTP Authentication.

At this point I decided I didn’t want to let the side down, and should probably build a Windows Phone 7 “Crime Hunter” app. As always its my belief that things done in mobile environments are always harder than on the desktop , you will see later why they aren’t with Phone 7, but this didn’t stop me from making a desktop application first.

While looking through the details of the API fo r this, I realised – this really is as simple as a web API gets – which makes it a perfect introduction for those who have never worked with a web API like this before. Nice simple and clean.

Desktop Proof Of Concept
This is a simple class with a single function that prints out the HTTP response. This serves simply to ensure that the API is working and returning Data. Pop in your API password and it should work straight away.

using System;
using System.Text;
using System.Net;
using System.IO;
using System.Web;

    class UkPoliceInterface
    {
        // API Credentials - Pass in by constructor in common use
        private string apiUsername = "";
        private string apiPassword = "";

        public string AuthorisedRequest(String requestUrl)
        {

            // Create a new WebRequest to the URL Passed
            WebRequest dataRequest = WebRequest.Create(requestUrl);

            // Add a BASIC Authentication header to the data request, using the API Username and Password
            dataRequest.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(apiUsername + ":" + apiPassword));

            // Wrap to catch errors
            try
            {
                // Request the response object and save it locally
                WebResponse dataResponse = dataRequest.GetResponse();

                // Get the response stream and wrap it in a stream reader
                StreamReader dataStreamReader = new StreamReader(dataResponse.GetResponseStream(), Encoding.UTF8);

                // Return the string
                return dataStreamReader.ReadToEnd();
            }
            catch (Exception ee)
            {
                // If Something went wrong, throw a generic exception at this time
                throw new Exception("Could Not Complete Web Query ("+ee.Message+")");
            }
        }
}

This function simply creates a new .NET WebRequest object, this neat little object encapsulates the process of making a request to a URI and provides a few methods for getting the response.

In the case, its sister object WebReponse takes the response and allows us to write it down to a stream, with the help of the StreamReader class , this means we can now write the stream down to a local string, and voila , theres the response. Some Lovely JSON…

[
    {
        "category": "vehicle-crime",
        "id": 1976260,
        "location": {
            "latitude": "52.6240688",
            "street": {
                "id": 165758,
                "name": "On or near Godsons Hill"
            },
            "longitude": "-1.4157945"
        },
        "context": "",
        "month": "2011-06"
    },
    {
        "category": "burglary",
        "id": 1976261,
        "location": {
            "latitude": "52.6240688",
            "street": {
                "id": 165758,
                "name": "On or near Godsons Hill"
            },
            "longitude": "-1.4157945"
        },
        "context": "",
        "month": "2011-06"
    },
    {
        "category": "vehicle-crime",
        "id": 2013093,
        "location": {
            "latitude": "52.6241922",
            "street": {
                "id": 203088,
                "name": "On or near Hillside"
            },
            "longitude": "-1.4153054"
        },
        "context": "",
        "month": "2011-06"
    },
    {
        "category": "anti-social-behaviour",
        "id": 2019201,
        "location": {
            "latitude": "52.6260645",
            "street": {
                "id": 209891,
                "name": "On or near Horseshoe Close"
            },
            "longitude": "-1.4212784"
        },
        "context": "",
        "month": "2011-06"
    },
    {
        "category": "other-crime",
        "id": 2245928,
        "location": {
            "latitude": "52.6233953",
            "street": {
                "id": 436377,
                "name": "On or near Warwick Lane"
            },
            "longitude": "-1.4033061"
        },
        "context": "",
        "month": "2011-06"
    },
    {
        "category": "burglary",
        "id": 2245929,
        "location": {
            "latitude": "52.6233953",
            "street": {
                "id": 436377,
                "name": "On or near Warwick Lane"
            },
            "longitude": "-1.4033061"
        },
        "context": "",
        "month": "2011-06"
    }
]

Now I knew that the API works as expected, on to coding it up for Windows Phone 7, See my part 2 Post on how!