Windows Phone 7 Manufacturer Market Share Stats

The following is a summary of the market share of Windows Phone 7 devices.  The sample is from those devices running applications using the www.AdGAC.com user control.

Device split by manufacturer:

AdGAC Windows Phone 7 Manufacturer Market Share Stats. HTC, Samsung, LG, Dell, Asus

AdGAC Windows Phone 7 Manufacturer Market Share Stats

Device split by model:

AdGAC Windows Phone7 Device Model Market Stats

If you would like to increase your market share through advertising, particularly if you are one of the brands above, please contact www.AdGAC.com

Enjoy,

Nick

Windows Phone 7 Social Viewer Application Template Released

Hi Guys,

The Social Viewer application template enables you to create mashups from Twitter, Facebook, RSS and Atom feeds with all the plumbing for security, sharing, offline, Trial mode and advertising support built in.

I have tried it out and the Social Viewer template really rocks its makes it extreemly fast and simple to create a mashup WP7 app.  Nick Randolph (Built To Roam) has really done an awesome job on this template.

You can get the full details, and template from Dave Glover in this blog posting. Also note he has mentioned a limited number of Tokens available to Australian devs for free WP7 marketplace registration – quite generous and a surefire way to kickstart your WP7 dev.

If you would like to see an app built with the Social Viewer template try out the Perez Hilton Reader

Kind Regards,

Nick Harris

We Love Windows Phone community video rocks

Announced at Mix11 at the start of the the Day 2 Keynote: Windows Phone fan Brandon Foy inspired our community and inspired Microsoft with his “We Love Windows Phone” video. We want to thank him by jump starting his resume. If just 200k people view his new video, we’ll air it in a national ad spot!

Now thats how funky the ads should be :) , lets get him up to 200k

Enjoy,
Nick

WP7 Nights at the Round Table Slide Deck March 31st

Hi there,

For those of you that were asking for the links here is the slide deck Meeting_WP7_Nights_at_the_Round_Table_Mar2011, that was presented on my phone :)

All in all a great night and we seen several cool new WP7  apps.

The app of the night was Mix11. Check it out here on Zune its free and will surely come in handy this month if your heading to Mix11 @ LA.  Description of Mix11 app follows:

Attending the Microsoft MIX11 conference in Las Vegas, April 2011? You need the complete shcedule on your Windows Phone 7 for quick and easy offline reference. Includes session information, speaker bios, a map and news feed. Favorite the sessions you plan on attending so you don’t accidentally miss one!

NOTE: the final schedule will not be announced until much closer to the date in April – the app will update over wifi or 3G. Until then, browse the schedules from previous conferences and watch the recorded sessions.

For those of you who dont have PowerPoint here is the March Rollup:

  1. Azure
  2. Windows Phone 7

Enjoy,
Nick

WP7 Nights at the Round Table – March 31

Hi there Windows Phone 7 Developers in Sydney Australia,

Time to get out from infront of the computer and into the bar to talk about Windows Phone 7 and Azure Dev :)

Event:
WP7 Nights at the Round Table – March 31st Sydney

Purpose:
Let’s get together for some drinks to trade WP7 Dev stories, demos or seek free advice from other devs to help get your app off the ground and into Marketplace. This event will be informal, around bar tables, so bring along your device or laptop if you wish to show people what you have been up to.

Let us know your coming:

If your on LinkedIn please indicate your attendance here – Windows Phone 7 Developer Dev Drinks March 31st or in the comments section below.

Date, Time, Location:

6-8pm
Thurs 31st March 2010
City Hotel,
Corner of King and Kent St, Sydney CBD.

Hope to see you there,

Nick Harris :)

WP7 Nights at the Round Table Slide Deck Feb

Hi there,

For those of you that were asking for the links here is the slide deck, that was presented on my phone :)

All in all a great night and we seen several cool new WP7  apps some of which were supported by Azure services.

The app of the night was What I Ate and Drank – a WP7 app with services and site both up on Azure. Check it out here on Zune its free.

Note: we are in need of a Logo if you got the design skills please feel free to create our group a free logo – creative inspiration could include WP7, Knights, Azure, Cloud Power, Sydney

Kind Regards,
Nick Harris

Two Great Competitions one for Windows Phone 7 and one for Azure

Hi there readers,

There are two great competitions I have come across that I think are well worth mentioning.

  1. The Windows Phone 7 LG App Starter Competition now in the Final Round run by Nick Randolph of Built To Roam.
  2. Windows Azure Marketplace: The DataMarket Contest run by codeproject

Both have great prizes and are well worth checking out.  Why not build a WP7 app that consumes free datasets from the Windows Azure Marketplace DataMarket and enter both ? :)

Kind Regards,

Nick Harris

Windows Phone 7 Navigation is not allowed when the task is not in the foreground

I hit the following issue bouncing around an app that utilised the SmsComposeTask today.  I have simplified the code to the following for demonstration purposes:

private void OnAdClick(object sender, MouseButtonEventArgs e)
{
   SmsComposeTask sms = new SmsComposeTask();
   sms.To = "111";
   sms.Body = "blah";  �
   sms.Show();
}

Issue:

When clicking the button that creates the SMS compose task in quick succession the following occurs.

InvalidOperationException

Navigation is not allowed when the task is not in the foreground. Error: -2147220989

at Microsoft.Phone.Shell.Interop.ShellPageManagerNativeMethods.CheckHResult(Int32 hr)
at Microsoft.Phone.Shell.Interop.ShellPageManager.NavigateToExternalPage(String pageUri, Byte[] args)
at Microsoft.Phone.Tasks.ChooserHelper.Navigate(Uri appUri, ParameterPropertyBag ppb)
at Microsoft.Phone.Tasks.SmsComposeTask.Show()
at Demo.OnAdClick(Object sender, MouseButtonEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
at Microsoft.Xna.Framework.Input.UnsafeNativeMethods.CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
at Microsoft.Xna.Framework.Input.SafeNativeMethods.CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
at Microsoft.Xna.Framework.Input.WindowMessageHooker.Hook.WndProc(IntPtr msgWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)

Cause:
The cause is that the first click will launch the SmsComposeTask causing the application to be deactivated i.e sent to the background, with the second click being handled after the deactivated event has occured so its just a matter of cleaning up your click handler.

Kind Regards,
Nick Harris

35ºC, 95ºF bedroom is like a sauna today, difficult to concerntrate, bring on autumn:)

WP7 Nights at the Round Table – Jan 25th

Hi there Windows Phone 7 Developers in Sydney Australia,

Following the success of our xmas Drinks we are going to make this a monthly event :) .  Time to get out from infront of the computer and into the bar to talk about windows phone 7 dev :)

Event:
WP7 Nights at the Round Table – Jan 25th Sydney

Purpose:
Let’s get together for some drinks to trade WP7 Dev stories, demos or seek free advice from other devs to help get your app off the ground and into Marketplace. This event will be informal, around bar tables, so bring along your device or laptop if you wish to show people what you have been up to.

Let us know your coming:

If your on LinkedIn please indicate your attendance here – http://events.linkedin.com/Windows-Phone-7-Dev-Drinks-Jan-25th/pub/536053 or in the comments section below.

Date, Time, Location:

6-8pm
Tues 14th Dec 2010
City Hotel,
Corner of King and Kent St, Sydney CBD.

Hope to see you there,

Nick Harris :)

Check if a Capability is enabled in WMAppManifest on Windows Phone 7

While Microsoft provides the handy Capability Detection Tool to determine what Capabilities are required for your application there are scenarios, one being that you are a provider windows phone 7 library, where you may want to check at runtime what capabilities are present in the WMAppManifest.xml. This post will provide a helper class to check each if each capability is present.

Note: This post leverages the great work done by Nick Randolph to gain access to the WMAppManifest.xml for access to the Application Product ID in his blogpost here

The helper class is as follows:

using Microsoft.Xna.Framework;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;

namespace www.NickHarris.NET
{
    public static class CapabilityHelper
    {
        private const string WMAppManifest = "WMAppManifest.xml";
        private const string ID_CAP_NETWORKING = "ID_CAP_NETWORKING";
        private const string ID_CAP_IDENTITY_DEVICE = "ID_CAP_IDENTITY_DEVICE";
        private const string ID_CAP_IDENTITY_USER = "ID_CAP_IDENTITY_USER";
        private const string ID_CAP_LOCATION = "ID_CAP_LOCATION";
        private const string ID_CAP_SENSORS = "ID_CAP_SENSORS";
        private const string ID_CAP_MICROPHONE = "ID_CAP_MICROPHONE";
        private const string ID_CAP_MEDIALIB = "ID_CAP_MEDIALIB";
        private const string ID_CAP_GAMERSERVICES = "ID_CAP_GAMERSERVICES";
        private const string ID_CAP_PHONEDIALER = "ID_CAP_PHONEDIALER";
        private const string ID_CAP_PUSH_NOTIFICATION = "ID_CAP_PUSH_NOTIFICATION";
        private const string ID_CAP_WEBBROWSERCOMPONENT = "ID_CAP_WEBBROWSERCOMPONENT";
        private const string CAPABILITIES = "Capabilities";
        private const string NAME = "Name";

        static CapabilityHelper()
        {
            using (var strm = TitleContainer.OpenStream(WMAppManifest))
            {
                var xml = XElement.Load(strm);
                var capabilities = xml.Descendants(CAPABILITIES).Elements();

                IsNetworkingCapability = CheckCapability(capabilities, ID_CAP_NETWORKING);
                IsDeviceIdentityCapability = CheckCapability(capabilities, ID_CAP_IDENTITY_DEVICE);
                IsUserIdentityCapability = CheckCapability(capabilities, ID_CAP_IDENTITY_USER);
                IsLocationCapability = CheckCapability(capabilities, ID_CAP_LOCATION);
                IsSensorsCapability = CheckCapability(capabilities, ID_CAP_SENSORS);
                IsMicrophoneCapability = CheckCapability(capabilities, ID_CAP_MICROPHONE);
                IsMediaLibCapability = CheckCapability(capabilities, ID_CAP_MEDIALIB);
                IsGamerServicesCapability = CheckCapability(capabilities, ID_CAP_GAMERSERVICES);
                IsPhoneDialerCapability = CheckCapability(capabilities, ID_CAP_PHONEDIALER);
                IsPushNotificationCapability = CheckCapability(capabilities, ID_CAP_PUSH_NOTIFICATION);
                IsWebBrowserComponentCapability = CheckCapability(capabilities, ID_CAP_WEBBROWSERCOMPONENT);
            }
        }

        public static bool IsNetworkingCapability { get; set; }
        public static bool IsDeviceIdentityCapability { get; set; }
        public static bool IsUserIdentityCapability { get; set; }
        public static bool IsLocationCapability { get; set; }
        public static bool IsSensorsCapability { get; set; }
        public static bool IsMicrophoneCapability { get; set; }
        public static bool IsMediaLibCapability { get; set; }
        public static bool IsGamerServicesCapability { get; set; }
        public static bool IsPhoneDialerCapability { get; set; }
        public static bool IsPushNotificationCapability { get; set; }
        public static bool IsWebBrowserComponentCapability { get; set; }

        private static bool CheckCapability(IEnumerable<XElement> capabilities, string capabilityName)
        {
            var capability = capabilities.FirstOrDefault(n => n.Attribute(NAME).Value.Equals(capabilityName));
            return capability != null;
        }     Â
    }
}

Note: You will need to add a reference to the Microsoft.XNA.Framework.dll for the helper to build. If you are concerned about the warning that shows up when adding a reference to this assembly from within a Silverlight application, rest assured, that it is possible to utilize most, but not all, XNA assemblies in a WP7 Silverlight Application as documented here on msdn. Scroll down to the section Using Classes Across Frameworks to see exclusions.

Usage is then as simple as

   if (!CapabilityHelper.IsUserIdentityCapability)
     //capability not present, do something

Enjoy,
Nick

Finding the Device Model on Windows Phone 7

Previously i detailed how to retrieve the Device Manufacturer and users anonymous id from the device here.  This post details how to capturing the Device Model on Windows Phone 7.

Step 1: Add the ID_CAP_IDENTITY_DEVICE capability to your WMAppManifest.xml

<Capabilities>
   <Capability Name="ID_CAP_IDENTITY_DEVICE"/>
   ...
</Capabilities>

Step 2: Use the DeviceName with DeviceExtendedProperties TryGetValue method as follows:

public static string GetDeviceModel()
{
   string model = null;
   object theModel = null;

   if (Microsoft.Phone.Info.DeviceExtendedProperties.TryGetValue("DeviceName", out theModel))
      model = theModel as string;      

   return model
}

The resulting Model of my device is T8697.

If you are interested in how to access your Applications ProductID, yep the one that can change during marketplace certification please see Nick Randolphs Blog here.

Enjoy,
Nick

Ad Platform for Windows Phone 7 with launch in Australia

Hey there good people of the internet, 

A while back I blogged about my Adventure Initiation about  2 to 3 weeks into it there was a minor hiccup in the form of an announcement that an Ad Platform being made available for Windows Phone 7.  In the spirit of finishing something that I gave so much to start I am pleased to announce that I have just had my showcase application for Windows Phone 7 certified. 

Just like any other new business you have to be able to perform all roles.  I guess its time to interview myself :)  

Whats is this showcase application?  

Well it is a preview application for AdGAC my Ad Platform for Windows Phone 7

Hold on I read Adventure Initiation you really left your paid employment to build an Ad Platform, are you crazy?  

You need to be  >= a little crazy to make steps forward.  

Well your interviewing yourself so you can tick the crazy box 

It would be my pleasure :)  

Why AdGAC? 

AdGAC, yep the name was inspired by the great .NET GAC :) .  But moreover it stands for Global Ad Community.  One of the biggest things I found I really really, really really, really did not like about advertising was the content rarely connected with anything I was interested in.  So what I did was integrate a toolbar into my Ad Control to allow me, the end user, the choice to personalise my ad experience thus helping with the prioritisation of content.  Furthermore if I configure it once it will it will travel between applications :) .  I see it as a win win win – win^3 – scenario for end users, advertisers and developers.  End users say what they want and hence will be engaged with the advertisers that want to connect with them and developers still make their hard earned cash. 

So what about a demo? 

I have made it so you can download the AdGAC preview application or you can search for it through marketplace using either “adgac” or “advertise” .  Sure, while the containing application is not beautiful it serves the purpose I built it for, that is, a vehicle to demonstrate the beauty of AdGAC Ad Platform i.e the advertisements and engagement model.  Be sure to use the flick up gesture to get your toolbar to personalise your profile for better matched content – note the effectiveness of this will become more apparent as more Ads are made available.  Here are some screenshots. 

AdGAC preview application

AdGAC preview application

AdGAC preview application

AdGAC preview application

What media types are supported for advertiser campaigns? 

We support text, image and animated gifs of dimensions 480×80 px 

What ways can Advertisers target their campaigns to capture the correct audiences attention? 

Currently we have 5 options available and some more under development.  The five available are: 

  1. by audience Interest
  2. by audience Gender
  3. by audience Age
  4. by Device Manufacturer
  5. by Audience Location

You can find more information here 

In what way can the end users interact with the Advertisers ad content , in other words what click action types / calls to action? 

Currently we have 5 options available and some more under development.  The five available are: 

  1. click to Website – good for directing traffic to your website
  2. click to Call – useful for directing calls into your corporate call centre e.g Charity organisations or Pizza companies
  3. click to SMS compose – useful for SMS promotions
  4. click to Marketplace Detail – useful for driving downloads of a single application or music that is available through Microsoft Marketplace
  5. click to Marketplace Search – useful for driving downloads of all your applications or music that is available through Microsoft Marketplace

You can find more information here 

How do you create campaigns and register applications? 

I  also built an accompanying website used by Developers to manage their applications  and  and Advertisers to manage their advertising campaigns www.AdGAC.com

AdGAC website Advertising for Windows Phone 7

AdGAC website Advertising for Windows Phone 7

Looks like you’ve been pretty busy? 

Surely have :)  

Where to now? 

  • Well I have opened the site for registrations of interest.  I would like to gauge stakeholder interest [ thats you :) ]  and would like to run a closed alpha to gather some feedback.   So if you’re a Developer or Advertiser and would like to be involved in the closed alpha then please do jump on the site www.AdGAC.com and go to the developer or advertiser tab and press Register or go direct through here Register and fill out the form
  • This release is streamlined to get the platform out for some feedback.  I have a whole bunch more ambitious ideas and the passion to implement them so stay tuned :)

Thanks for your time Nick 

No problems 

To my dear tech readers -  you now probably understand why the tech posts this month were fewer then usual I look forward to getting you some more tech when I am back from my holiday early Jan .  Until then, happy Christmas and New Year! 

Kind Regards, 

Nick Harris

How to Reverse Geocode a Location to an Address on Windows Phone 7

I have had a few people recently ask me how to reverse geocode a location to an address on Windows Phone 7.  The answer should be straightfoward but at the moment thats not quite true.

So whats the straightforward answer supposed to be?

Well glad you asked :) It should be to use the CivicAddressResolver class and its ResolveAddressAsync method

Ok so whats the Gotcha?

When you try to resolve an address CivicAddressResolver all you get back is a empty CivicAddress.  Yep the resolve method is not implemented.

So what options do you have?

  1. Wait for the CivicAddressResolver to be implemented. Note: At the time of writing I have not heard of when it will be released.
  2. Use the Bing Maps API to perform your reverse geocode in one of the following ways
    • Add a service reference from your WP7 project to the Bing Maps SOAP API <–  Requires Bing Maps Key to be supplied in code so not ideal as we want to protect this.
    • Call the Bing Maps REST API from within your WP7  project <–  Requires Bing Maps Key to be supplied in code so not ideal as we want to protect this.
    • Either of the above two options but access your  Bing Maps Key on a service and request it over SSL for device use – ensures XAP  does not contain key but still returning it to the device over the wire
    • Proxy the call to the Bing Maps REST API in your own WCF Service so your Bing Maps Key never hits the device <– ideal method until CivicAddressResolver is implemented.

If you would prefer grab the code then reading through here it is – You can download the code from this linked page

The remainder of this post will detail how to go about implementing the last option above i.e Proxy the call to your own service so that the Key is not available on the WP7 device.

Creating the WCF Service

  1. In Visual Studio 2010 File –> Add New Project –> Select WCF Service Application
  2. Name the Project “ReverseGeocodeService”
  3. On ReverseGeocodeService Right Click –> Add Reference –> Select System.Configuration (we will use this for retrieving your Bing Maps key from configuration).
  4. Set the project to use the local IIS webserver as the host.  On ReverGeocodeService Right Click –> Properties –> Web –> select Use Local IIS Web server and provide a project URL of http://localhost/ReverseGeocodeService
  5. Create the following Folder structure and add the following files within your service
  6. Create your BingLocationResponse class as follows:
  7. Note this class details the how to serialize and deserialize a response from the Bing Maps Rest API and we will use it deserialize the JSON response from the Bing Maps REST API and then also use it both to return a response to the WP7 client

    using System.Runtime.Serialization;
    
    namespace ReverseGeocodeService.Contracts.Data
    {
        [DataContract]
        public class BingLocationResponse
        {
            [DataMember]
            public string authenticationResultCode { get; set; }
            [DataMember]
            public string brandLogoUri { get; set; }
            [DataMember]
            public string copyright { get; set; }
    
            [DataMember]
            public ResourceSet[] resourceSets { get; set; }
    
            [DataMember]
            public string statusCode { get; set; }
            [DataMember]
            public string statusDescription { get; set; }
            [DataMember]
            public string traceId { get; set; }
    
            [DataContract]
            public class ResourceSet
            {
                [DataMember]
                public int estimatedTotal { get; set; }
    
                [DataMember]
                public Resource[] resources { get; set; }
    
                [DataContract(Namespace = "http://schemas.microsoft.com/search/local/ws/rest/v1", Name = "Location")]
                public class Resource
                {
                    [DataMember]
                    public string __type { get; set; }
    
                    [DataMember]
                    public double[] bbox { get; set; }
    
                    [DataMember]
                    public string name { get; set; }
    
                    [DataMember]
                    public Point point { get; set; }
    
                    [DataContract]
                    public class Point
                    {
                        [DataMember]
                        public string type { get; set; }
    
                        [DataMember]
                        public string[] coordinates { get; set; }
                    }
    
                    [DataMember]
                    public Address address { get; set; }
    
                    [DataContract]
                    public class Address
                    {
                        [DataMember]
                        public string addressLine { get; set; }
                        [DataMember]
                        public string adminDistrict { get; set; }
                        [DataMember]
                        public string adminDistrict2 { get; set; }
                        [DataMember]
                        public string countryRegion { get; set; }
                        [DataMember]
                        public string formattedAddress { get; set; }
                        [DataMember]
                        public string locality { get; set; }
                        [DataMember]
                        public string postalCode { get; set; }
                    }
    
                    [DataMember]
                    public string confidence { get; set; }
    
                    [DataMember]
                    public string entityType { get; set; }
                }
            }
        }
    }
  8. Next Define the Interface for your WCF service IGeocodeService.cs and your Geocode Provider that will call out to Bing Maps
  9. IGeocodeService.cs:

    using System.ServiceModel;
    using ReverseGeocodeService.Contracts.Data;
    
    namespace ReverseGeocodeService.Contracts
    {
        [ServiceContract]
        public interface IGeocodeService
        {
            [OperationContract]
            string GetAddress(double latitude, double longitude);
    
            [OperationContract]
            BingLocationResponse GetFullAddress(double latitude, double longitude);
        }
    }
    

    IGeocodeProvider.cs:

    using System;
    using ReverseGeocodeService.Contracts.Data;
    namespace ReverseGeocodeService.Contracts
    {
        public interface IGeocodeProvider
        {
            BingLocationResponse ReverseGeocode(double latitude, double longitude);
        }
    }
  10. Implement your GeocodeProvider.cs
  11. This class will call out to the Bing Maps REST API return its deserialized its response. If you want to see what other options Bing Maps REST API provides you should use this as your starting point and more specifically for the Locations by Point we are using in this example see this

    using System;
    using System.Diagnostics;
    using System.Net;
    using System.Runtime.Serialization.Json;
    using ReverseGeocodeService.Contracts;
    using ReverseGeocodeService.Contracts.Data;
    
    namespace ReverseGeocodeService.Providers
    {
        public class GeocodeProvider : IGeocodeProvider
        {
            private readonly string _bingMapsKey;
            private string _bingMapsRESTUri = "https://dev.virtualearth.net/REST/v1/Locations/{0}?key={1}";
            public GeocodeProvider(string bingMapsKey)
            {
                _bingMapsKey = bingMapsKey;
            }        
    
            public BingLocationResponse ReverseGeocode(double latitude, double longitude)
            {
                BingLocationResponse result = null;
                string formattedLocation = string.Format("{0},{1}", latitude, longitude); //bing maps requires Lat,Long
                var request = HttpWebRequest.Create(string.Format(_bingMapsRESTUri, formattedLocation, _bingMapsKey)) as HttpWebRequest;
                try
                {
                    using (var response = request.GetResponse() as HttpWebResponse)
                    {
                        result = GetResult(response);
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                }
    
                return result;
            }
    
            private BingLocationResponse GetResult(HttpWebResponse response)
            {
                BingLocationResponse location = null;
                if (response != null && response.StatusCode == HttpStatusCode.OK)
                {
                    //Deserialize the response and provide the address to the callback action
                    using (var stream = response.GetResponseStream())
                    {
                        DataContractJsonSerializer serialiser = new DataContractJsonSerializer(typeof(BingLocationResponse));
                        location = serialiser.ReadObject(stream) as BingLocationResponse;
                    }
                }
    
                return location;
            }
        }
    }
  12. Finally implement your WCF Service GecodeService.svc.cs as follows
  13. Note that the BingKey is externalised into your config files appSettings, for the example to work you will need to supply your key to the config file.

    using System.Configuration;
    using System.Linq;
    using System.ServiceModel;
    using ReverseGeocodeService.Contracts;
    using ReverseGeocodeService.Contracts.Data;
    using ReverseGeocodeService.Providers;
    
    namespace ReverseGeocodeService
    {
        [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
        public class GeocodeService : IGeocodeService
        {
            //TODO: set your bingkey in config appsetting named BingKey
            private static IGeocodeProvider _geocodeProvider = new GeocodeProvider(ConfigurationManager.AppSettings["BingKey"]);
    
            public string GetAddress(double latitude, double longitude)
            {
                string formattedAddress = null;
                var geocodeResult = _geocodeProvider.ReverseGeocode(latitude, longitude);
                if (geocodeResult != null
                                && geocodeResult.resourceSets != null
                                && geocodeResult.resourceSets.Any()
                                && geocodeResult.resourceSets.First().resources != null
                                && geocodeResult.resourceSets.First().resources.Any())
                {
                    formattedAddress = geocodeResult.resourceSets.First().resources.First().address.formattedAddress;
                }
    
                return formattedAddress;
            }
    
            public BingLocationResponse GetFullAddress(double latitude, double longitude)
            {
                return _geocodeProvider.ReverseGeocode(latitude, longitude);
            }
        }
    }
  14. Add the appSettings section to your Web.config and supply your Bing Maps API Key
  15. <configuration>
     <appSettings>
        <add key="BingKey" value="Bing Maps Key Here"/>
      </appSettings>
      ...
    </configuration>

    Note: you should encrypt this Key using whatever standard practices you use.

Creating the Windows Phone 7 Client

Note: this is not an example of how to create an MVVM implementation on WP7  i.e we are focusing on how to reverse geocode a location to an address through the use of a proxy service  to protect your Bing Maps Key as such in this post the client code is kept straightforward to demonstrate usage.

  1. Add a Windows Phone 7 project File --> New Project --> Silverlight for Windows Phone --> Windows Phone Application
  2. Name the project ReverseGeocode
  3. On the project Right Click --> Add Service Reference --> Press Discover.
  4. You should see a window as in the following image.  Provide the Namespace ReverseGeocodeClient and Press OK
  5. Note: If this step is generating an Empty ServiceReferences.ClientConfig then delete the Service References and Service References.ClientConfig. Close all instances of Visual Studio. Open Visual Studio and try to add it again - it worked for me :) . If this still doesn't work then you will need to use SlSvcUtil.exe located in your Program Files (Program Files (x86)) for 64bit machines as follows:
    C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Tools\SlSvcUtil.exe" http://localhost/ReverseGeocodeService/GeocodeService.svc?wsdl
    Take the two files from the output and include them in your project and continue.

  6. Right click on the generated ServiceReferences.ClientConfig and set its Build Action to Content and Copy to Output Directory to Copy if newer
  7. Add a couple of buttons to perform calls out to the service in your MainPage.xaml and a TextBlock to display the result
  8. <phone:PhoneApplicationPage
        x:Class="ReverseGeocode.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
        xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
        FontFamily="{StaticResource PhoneFontFamilyNormal}"
        FontSize="{StaticResource PhoneFontSizeNormal}"
        Foreground="{StaticResource PhoneForegroundBrush}"
        SupportedOrientations="Portrait" Orientation="Portrait"
        shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">
    
        <!--LayoutRoot is the root grid where all page content is placed-->
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
    
            <!--TitlePanel contains the name of the application and page title-->
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>
    
            <!--ContentPanel - place additional content here-->
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <Button Click="btnGetAddress_Click" Content="Get Address" Height="72" HorizontalAlignment="Left" Margin="6,6,0,0" Name="button1" VerticalAlignment="Top" Width="270" />
                <TextBlock x:Name="txtAddress" Height="203" HorizontalAlignment="Left" Margin="12,163,0,0" Text="Address goes here" VerticalAlignment="Top" Width="425" />
                <Button Content="Get Full Response" Height="72" HorizontalAlignment="Left" Margin="5,72,0,0" Name="button2" VerticalAlignment="Top" Width="270" Click="btnGetFullResponse_Click" />
            </Grid>
        </Grid>
    
    </phone:PhoneApplicationPage>
  9. Update your codebehind, MainPage.xaml.cs to call out to your new Reverse geocoding service when buttons are clicked
  10. using System;
    using System.Linq;
    using System.Windows;
    using Microsoft.Phone.Controls;
    using ReverseGeocode.ReverseGeocodeClient;
    
    namespace ReverseGeocode
    {
        public partial class MainPage : PhoneApplicationPage
        {
            private GeocodeServiceClient _client;
            private const string NO_RESULT_FOUND = "No Result Found";
            // Constructor
            public MainPage()
            {
                InitializeComponent();
            }
    
            private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
            {
               _client = new GeocodeServiceClient();
               _client.GetAddressCompleted += new EventHandler(client_GetAddressCompleted);
               _client.GetFullAddressCompleted += new EventHandler(_client_GetFullAddressCompleted);
            }
    
            private void btnGetAddress_Click(object sender, RoutedEventArgs e)
            {
                _client.GetAddressAsync(-33.796526, 151.138267);
            }        
    
            private void btnGetFullResponse_Click(object sender, RoutedEventArgs e)
            {
                _client.GetFullAddressAsync(-33.796526, 151.138267);
            }
    
            void client_GetAddressCompleted(object sender, GetAddressCompletedEventArgs e)
            {
                txtAddress.Text = e.Result ?? NO_RESULT_FOUND;
            }
    
            void _client_GetFullAddressCompleted(object sender, GetFullAddressCompletedEventArgs e)
            {
                string result = NO_RESULT_FOUND;
                if (e.Result != null
                                && e.Result.resourceSets != null
                                && e.Result.resourceSets.Any()
                                && e.Result.resourceSets.First().resources != null
                                && e.Result.resourceSets.First().resources.Any())
                {
                    var x = e.Result.resourceSets.First().resources.First();
                    result = string.Format ("Address:\n{0}\nConfidence:\n{1}\n", x.address.formattedAddress, x.confidence);
                }
    
                txtAddress.Text = result;
            }
        }
    }

    Note: I have not done it in this example however when you are finished with your _client you should always call _client.CloseAsync();

Summary:
And there you have it - in the absence of CivicAddressResolver this provides an implementation to reverse geocode a latitude and longitude into an Address on Windows Phone 7 without the need for your Bing Maps key to either be stored in the XAP or retrieved from a service by keeping your key within the context of your WCF proxy service.

You can download the code from this linked page - note you will have to add your Bing Maps Key to the web.config for it to work and also create the virtual directory on local host as detailed in the WCF service steps.

I hope this has helped you save some time :)

Enjoy,
Nick

Lets have Windows Phone 7 Dev XMass Drinks in Sydney

Hi there Windows Phone 7 Developers in Sydney Australia,

I thought it would be cool to meet each other in person over some informal XMass drinks. So without any further delay, here are the details:

Event:
WP7Dev XMass Drinks meet and greet

Please indicate your attendance here – http://events.linkedin.com/Windows-Phone-7-Developer-XMass-Drinks/pub/496913

Purpose:
Let’s get together for some XMass Drinks and/or dinner to trade some WP7 Dev stories and demos. Event will be informal, i.e around bar tables, so bring along your device or laptop if you wish to show people what you have been up to.

Date, Time, Location:

6-8pm
Tues 14th Dec 2010
City Hotel,
Corner of King and Kent St, Sydney CBD.

Hope to see you there,

Nick Harris :)

Using TouchPanel for Gestures in Windows Phone 7

The Silverlight for Windows Phone Toolkit has some excellent controls, one of which is the GestureListener which makes implementing gesture support a very straightforward task.   However, as happens from time to time you’re hit with a scenario where you’re unable to depend on any third party content and as such I needed to add my own basic handling for gestures.  This is how you do it:

1. Add reference to Microsoft.Xna.Framework.Input.Touch.dll – Note: you will get a warning here that you can ignore for now.

2. In code behind  the gestures you want to listen for

The Gesture types you can enable are as follows Tap, DoubleTap, Hold, HorizontalDrag, VerticalDrag, FreeDrag, Pinch, Flick, DragComplete, PinchComplete

In my case I only want to deal with Flick, Hold and Tap therefore add the following:
TouchPanel.EnabledGestures = GestureType.Flick | GestureType.Hold | GestureType.Tap;

3. Limiting the scope for the gestures.

I want the gestures to be captured only when performed in a given for a StackPanel.  To do this I handle the ManipulationCompleted event on the StackPanel as follows:

<StackPanel ManipulationCompleted="StackPanel_ManipulationCompleted">

...

</StackPanel>

Note: if you wanted the gesture available to the content of the whole page then you would handle the ManipulationCompleted event of the PhoneApplicationPage.

4. Add handling code as follows


private void StackPanel_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
   //Check if touch Gesture is available
   if (TouchPanel.IsGestureAvailable)
   {
      // Read the gesture so that you can handle the gesture type
      GestureSample gesture = TouchPanel.ReadGesture();
      switch (gesture.GestureType)
     {
         case GestureType.Flick:
         case GestureType.Hold:
            ToggleToolbarVisibility();
         break;
         case GestureType.Tap:
            Navigate();
         break;
         default:
            //do something
         break;
      }
   }
}

Enjoy,

Nick

Windows Phone 7 and HTC 7 Mozart Review

I have had a several days to play with my new HTC 7 Mozart  now and I must say overall I am really impressed.  Having taken photos, emailed, used sms, used facebook, downloaded applications, watched video, listened to music, podcasts and the radio,  used the maps app to get directions, used Bing to find content, booked a steak night in my Windows Live Calendar and so much more.

The Hardware (HTC 7 Mozart):

Model – T8679

CPU – 1 GHz

Platform – Windows Phone OS 7

Memory – 512 ROM and 576 RAM

Size and Weight – 119 x 60.2 x 11.9 mm, 130 grams

Display – 3.7-inch touch screen

GPS – Internal GPS antenna

Network -

  • HSPA/WCDMA (850/2100 MHz)
  • GSM/GPRS/EDGE (850/900/1800/1900 MHz)

Connectivity -

  • Bluetooth 2.1 with A2DP
  • Wi-Fi: IEEE 802.11 b/g/h
  • 3.5 mm stereo audio jack
  • Standard micro-USB

Camera -

  • 8 megapixel colour camera with auto focus and Xenon flash
  • 720p HD video recording

1. Face

– note my camera really does not do this Justice :(

2. Back

3. Top

4. Bottom

5. Side

6. Side

So what did I enjoy about my new Windows Phone 7 experience:

Well pretty much everything rocks, I don’t really go anywhere anymore without my phone and its only been 6 days :)

The whole Metro experience is definitely s3xy and slick the WP7 team have really done a fantastic job, if I ever met anyone of you then you would definitely receive a well deserved hug.

Nick + push notifications == love.  At the moment I am just starting to see some  third party apps out there starting to use them.  The build in phone, SMS, email and people tiles are using Live Tiles to bring your Start screen to life keeping  you informed e.g how many emails or SMS you have.  Some applications are also using toast notifications e.g SMS when it comes in and also AlphaJax a turn by turn based game to notify me when its my turn.  No picture could do the Start screen Live Tiles justice.  I would recommend that you check them out in action here for yourself or get your hands on a device to play with.

The People hub == awesome.  I can see whats going on with my Facebook, Windows Live and LinkedIn contacts, thats right I am watching you people, as well as post comment on their status.  You can even Pin some of your contacts to your Start screen and you get a nice Live Tile of that person on there that will show their updates as they come through.

The Pictures Hub and Camera is pretty cool. You can easily setup Zune to sync your pictures bidirectionally between your phone/PC .  Further you can configure your phone to upload the pictures you take to your windows Live Skydrive you can share your pics on facebook.     For those of you a bit hesitant to have photos uploading to Skydrive directly keep in mind that you can configure the uploaded files to be private.  Settings –> Applications pivot –> Pictures and camera — Auto upload to SkyDrive.  When selecting this you it will give you options on how visible you want the photo e.g private, friends, public etc.

Music and Video Hub, using Zune I was able to sync down music from my personal collection buy a Video to watch on the device and also listen to the radio.  Like the people hub you can pin items from here to your start screen as well.

Speech recognition and speech synthesis.  If you press down on your Start button your phone will start listening for your commands.  E.g “Call Adam Harris”, “Open Boom Baby” and if your not in Australia “Find local Pizza”.   You can also set speech to work when in locked mode through Settings –> Speech –> Use Speech when in locked mode.

If your a big fan of gaming you will also love the XBox Live Integration and I also find the Location Map application using Bing Maps is really handy.  One little know feature that i think is a good idea is the Find a Lost phone idea where you can lock your phone, see itslocation and even remote wipe it to see the full list of stuff you can do here check this out

So its been 6 days and I have had a good dig around through the Marketplace Hub, bought several apps and also used Trial mode on a few to see if i liked them.  Her here some of the gems I have found.

Apps:

  • Couch to 5k – This is the first application I purchased.  It is designed to help you move up to running 5km (which I have never been able to do) within 9 weeks. Will let you know how I go
  • Yoink – is a really cool concept you can get stuff free and also give stuff away in your local area straight from your WP7 device
  • Channel 9 – stream Channel  9 content
  • Ted – looking for inspiration then Stream some TED content
  • Facebook
  • BoomBaby – Download if your a developer and after using it if you are thinking whats that about my question to you is – Where were you?

Games:

  • Max and the Magic Marker – Awesome use of a physics engine.  Seriously, download it and test it out in trial mode now.
  • AlphaJax – A cool word game, sort of like comparable scrabble.  You can play a random person or call out for a game to  friends  on facebook or twitter.  The game also has an in application chat feature and is the first game where I have seen push notifications being used.
  • Unite – Uses your phones accelerometer to move balls around obstacles with the goal of uniting them.  Pretty cool actually.
  • RocketRiot – good for a bit of  rocket blasting and jetpack fun
  • Helicopter – first application that I have come across with Ad Content within it.  Still a fun application
  • Krashlander – This was fun also, i liked the design of the control overlay on the screen. I think it will be interesting to see what the new updates to this game will have

Theres a lot more that I could go into that I liked but I could quite literally go on forever.  In fact if you have read this far through I applaud you :) , keep going :)

What could be refined and/or improved – in no particular order:

  1. While the phone has many features it seems like some extra cool features are available in the United States but are missing for us Australians :( .  It would be great to see the following features available in Australia or I may just have to move to the United States:
    • Music Purchase directly in phone, or direct on PC, from Zune Marketplace
    • Music “Rental” i.e Zune Pass Marketplace – pay per month listen to as much music as you want and keep 10 at the end of each month.
    • Location and Direction features
      • Support Local Search results  Bing result pivot
      • Support Speech Find command
      • Support Clickable addresses to Maps from emails and websites etc.
  2. When we talk about developers its Developer Developers Developers, when you talk about a large proportion of consumers its not just Video it is also – Music Music Music.  The Music and Video hub is great and Zune helps sync the movies you have purchased through Zune onto the device.  As for music, currently in Australia you are unable to purchase music through Zune Marketplace or directly on the phone.  For many consumers including the one non tech female I tested it on it was something expected as an essential feature.  I assume that Zune Marketplace would open for music sometime in the future within Australia – lets hope its before everyone gets their new shiny device for Christmas – Anyone got any announcements about when this may happen?

  3. Improvements for Map Application that comes out of the box:
    • Enable drag on waypoints within map directions for re-routing.
    • Directions given by voice synthesis when driving
  4. Squeeze some more Battery Life –  I have not had major problems e.g only recharge about every 24hrs and i do listen to the radio, check email, and stream Channel 9 and TED sessions daily.  Here are some further small suggestions that could be made that would enable those who want to make the most of their battery to take it one step further:
    • Vibration feedback on Back, Search and Start button press is not configurable – even when the battery level is critical.  For me personally while the vibration feedback is cool, i would like to be able to turn off the vibrate for these virtual buttons through settings to help conserve battery.
  5. Zune Video Rentals – So this is available in Australia.  Rent for 14days or 24hours after first play.  Cost is about 350 credits – a bit steep…. well come on I don’t have a job :) .   As for an improvement with the rentals it would be cool if this too kept up with the always connected user experience.  Example I rented a movie to my Device and then Synchronized the copy of the Video back onto my PC for watching through Zune.  On attempting to watch through Zune it reports – “You have already used the maximum number of licenses for this item”.  So the experience I would expect here is sure the rental rules above apply.  But hey watch 1/2 on the desktop then go catch a train/bus/tram and watch the other half on your phone – This would rock :) .
  6. So what movie did I watch – Crazy Heart, was pretty cool and I must say having never been to the US the  landscape in the film is awesome.  And if your not using the HTC HD7 with built in stand, you can improvise with a Windows Phone cap :)
  7. I want the music on here to be available in the ringtones -Â

The Developer Platform:

The developer platform for WP7 is world class and even better its free :) I recommend that you jump in and try it out yourself.  Here is a link to a great starting place for getting your free developer tools - App Hub Downloads

In addition to these I recommend you check out

  1. Azure – I believe Azure is going to be an enabler for many great WP7 applications – got an application idea that needs to scale, process and/or store data in the cloud?
  2. OData SDK for WP7 – Makes easy work of consuming OData feeds.
  3. Sync Framework 4.o October 2010 CTP – enable data sync scenarios for WP7, iPhone, WM, Silverlight and more
  4. Silverlight Toolkit for Windows Phone 7 on Codeplex – a great bunch of controls for the UI.

Summary:

Windows Phone 7  Rocks and is a huge leap forward for both consumers and developers – it is “My Preeeeciouous” (Gollem, Lord of the Rings)

Now back to development :)

Nick

Note: if you want to have a play around on my device please feel free to approach me at http://thesaug.org this Thursday night 25/11/2010.

Tips for a Fast Windows Phone 7 Developer Phone Registration

Steps to register a Windows Phone 7 device:
  1. Open Zune on your PC
  2. Turn on your WP7 device and unlock the screen
  3. Connect your device and ensure Zune can see your WP7 device
  4. Open the Windows Phone Developer Registration Application (All Programs –> Windows Phone Developer Tools –> Windows Phone Developer Registration).  This tool should display a status showing that the phone is ready.
  5. Enter your Windows Live ID and password then click Register
  6. If all goes well you should see a message. Registration successful.

At this stage it should have all worked.  If it didn’t you should read on.

Tips for ensuring successful registration of the phone – Step 6 above:

  1. Prepare for GeoTrust verification early. Get a phone  Phone Bill that is <= 6 months old,  scanned  that shows your name  or Company Name (same as applying in app hub) and your your phone number.  If you don’t have this you will have to get a template letter they provide signed and witnessed by someone like a JP.
  2. Ensure you have a phone plugged in for GeoTrust to call you on :)
  3. You need to have signed up on App Hub.
  4. You need to have gone through the GeoTrust verification process – phone call and bill provided.

So what next, you may find that GeoTrust have called and verified you but the Windows Phone Developer Registration Application still fails. In my case it was with the following error:

Status: Marketplace registration incomplete. Please return to the developer portal for more information. (ErrorCode:0×80043009)

Solution: So it turns out this means that your GeoTrust identity verification is incomplete.  But thats weird right, they just verified you.  You can double check the by logging into your App Hub and going to My Dashboard –> Windows Phone.

If the Publisher identity verification  is not complete you will not see a tick as per below and in its place you will see an Arrow:

So what do you do, particularly in Australia:

The FAQ states to to contact GeoTrust support chat: https://www.geotrust.com/support/chat/order-processing.html

After trying this a number of times I was never able to get through to the chat.  It was always asking which state in the US you are from and also for the order ID.  After entering Aust over a couple of days and having to send an email with a description of the problem I had not heard back.

So I decided to move to Washington for about 30 minutes :) , and within seconds I was in a chat.  Apparently the issue was they needed another email address that included my name.  After giving them the extra detail they then said it should be processed by Microsoft within 24hours.  ~3hours later the job was done – fast, Azure worker roles?.   You can check within App Hub by verifying the Publisher identity verification is correct,  You will see a tick as per the following

At this point you should then run through the steps at the top of this article to register your phone.  If that too is successful it the Status in the Windows Phone Developer Registration Application will indicate so.

Hope these tips help save you a couple of days :)

Nick

Unboxing the HTC 7 Mozart

Being a mobile developer that has targeted windows mobile devices for over 6 years  now I was happy to see Windows Phone 7  announced, delivered and as of last Thursday even happier to have a device I was fortunate enough to win at the PDC replay delivered to my hands by Christian Longstaff.  The device you ask is a HTC 7 Mozart – but first the traditional unboxing.

Wrapping:

The wrapping paper is a personal touch from someone at Microsoft.  Judging by the amount of sticky tape on the sides + back and on my own shocking gift wrapping abilities I would be guessing it was a developer, or new receptionist, that wrapped this :)

Box:

Box Open:

Initial Warning:

To Prevent damage, do not apply excessive pressure to the screen or device case. Please remove the device from your pants pocket before sitting down. For more details, see the Quick Start Guide.

Wasting no time – Initial Power Up:

- Beautiful

After a bit of personalisation:

- More on the pink tiles in my coming Review


Stay tuned, I am working on a Review and it should be up in the next couple of days after I have a chance to dig a bit deeper and play with more apps :)

Nick

How to Create a Custom Pushpin Control Template in Expression Blend for Windows Phone 7 Bing Maps

You may find yourself building a Windows Phone 7 application with the Bing Maps control. When you add the default Pushpin to your map you map you may find that you want a little more, perhaps to establish your brand a bit more or to make the pushpin fit in with the rest of your application. This post details the basics of how to create a Custom Pushpin Control Template in Expression Blend.

Steps are as follows:

  1. Open Visual Studio – yes we are going to start from here :)
  2. File –> New –> Project …
  3. Select Silverlight for Windows Phone then Windows Phone Application.  Name the project CustomPushpin and click Ok.
  4. Right click on your project in Visual Studio and select Open in Expression Blend…
  5. In Blend select the projects tab, Right Click on References and add a Reference to C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Libraries\Silverlight\Microsoft.Phone.Controls.Maps.dll
  6. Select the Assets Tab and type in Map
  7. Drag the Map control onto the page then right click and select Auto Size –> Fill
  8. Set the mode on the map to Aerial
  9. In the Assets Tab drag on a MapItemsControl
  10. In the Assets Tab type inPushpin and Drag two Pushpins onto the Map
  11. In the Properties tab change the color of one Pushpins to red so that it stands out
  12. Select the remaining Pushpin and right click –> select Edit Template –> press Edit a Copy…
  13. In the Create ControlTemplate Resource specify the Name (key) for the resource to be CustomPushpinControlTemplate and press Ok
  14. Crate your custom Pushpin using the blend tools
  15. End Result – yes I am not much of a graphic designer ;)
  16. Note that now when you add new pushpins all you can re-use this template. This can be done through the XAML or on the properties tab in the Miscellaneous group.  Select Template, Local Resource, CustomPushpinTemplate.
  17. Save your blend project and return to Visual studio.  It will prompt you to reload the project.  Click Reload.

Note: rather then having gradient fills, Ellipse etc as your custom template, you could simply add an image to your project and set the image control to that resource in your custom template. Just ensure your build action on the image is Content.

From a developer perspective Blend did make it quite fast to create a custom Pushpin with some nice gradients.    From here i could take the output and start building in my MVVM implementation to add my Pushpins from a service feed or through capturing user clicks.

You can download the output from the blend session here: Full Visual Studio Solution

Enjoy,

Nick

MarketplaceReviewTask

A question come up on the App Hub forums a few days back and I thought it would be an interesting one to talk through.  The question was along the following lines:

  1. Is there a way to capture reviews of your application?
  2. What is the general user a opinion about ‘Nag’ screens that pop up asking for a product review as seen in some iPhone Applications
  3. What is an acceptable method when asking for Reviews i.e ‘Nag’ screen verse passive link

To answer these questions we need to look at the MarketplaceReviewTask and Windows Phone 7 Application Certification Requirements. - Note you can always find the latest version of the application certification requirements over on App Hub 

  1. Is there a way to capture reviews of your application?
  2. First I some people may wonder why would you want a review, well – allowing users to review your application will help (well depends on the review :) ) you stand out in what will eventually become a very competitive marketplace.  Good reviews will ultimately help to drive downloads of your application.   To provide the user the ability to review you application the Microsoft.Phone.Tasks namespace provides the  MarketplaceReviewTask specifically for this reason.  Now before we jump to the code for implementing this I think it is first important to talk through the remainder of the questions.

  3. What is the general user a opinion about ‘Nag’ screens that pop up asking for a product review as seen in some iPhone Applications?
  4.  I for one am definitely not keen on nag screens of any description, for the simple reason that they can be annoying and can turn someone from enjoying their in app experience and by extension, for many non tech users, their windows phone 7 experience.

  5. What is an acceptable method when asking for Reviews i.e ‘Nag’ screen verse passive link
  6. The general rule of thumb here is that the Windows Phone 7 Application Certification Requirements detail whats ok and whats not ok.  But like any document its difficult to put in every single thing upfront and as a result documents evolve over time.  Currently there is no mention of MarketplaceReviewTask nag screens.  However as a developer I would urge you not to take such a path.  On one hand you may get your reviews through brute force nagging but on the otherhand you may just frustrate your users until they uninstalling the app (I would) or writing a bad review.  In my opinion as devs we need to keep in mind that applications play a big role in the success of WP7 adoption.  If we can have happy rather then frustrated users then we are in a good position to continue moving forward.   Thats why i like the suggestion in the forum of using a passive Submit a Review link in the application and  here is how you would implement it in code.

To implement you use the Microsoft.Phone.Tasks; namesplace and the MarketplaceReviewTask.

In your page add the following XAML:

<HyperlinkButton Content="Submit A Review" Height="30" HorizontalAlignment="Left" Margin="225,665,0,0" Name="btnSubmitReview" VerticalAlignment="Top" Width="200" Click="btnSubmitReview_Click" />

In the code code behind of your page add:

using Microsoft.Phone.Tasks;

and add code to your handler as follows:

private void btnSubmitReview_Click(object sender, RoutedEventArgs e)
{
     MarketplaceReviewTask review = new MarketplaceReviewTask();
     review.Show();
}

The end result is as follows:

MarketplaceReviewTask

MarketplaceReviewTask

Note:
1. The MarketplaceReviewTask will cause your application to be tombstoned so you will need to add handing for that.
2. Running this in the emulator will display a warning/error dialog.

Enjoy,
Nick :)

Windows Phone 7 Dev News

What an exciting time to be a developer. I have to say attending PDC shed some light on some seriously cool leaps forward in the Microsoft technology stack IE9, HTML5, Azure and you guessed it Windows Phone 7. This post is a update on the recent Windows Phone 7 related dev tool announcements:

  1. Updated OData Client Library for Windows Phone 7  
  2. Windows Phone 7 analysis tools – not yet released but would love to get my hands on it eary
  3. At PDC an upcoming performance analysis tool to run an instrumented version of your app on devices to provides profiler data in Visual Studio was demonstrated. In the demo the profiling performed gave data on CPU utilisation, frames per second and storyboard animations.

  4. Application Analytics and Code Obfuscation for Windows Phone 7 and Windows Phone Marketplace
  5. Free analytics and code obfuscation for WP7. Well worthwhile using to analyse how your users use your apps and protect your IP through obfuscation

  6. Sync Framework v4 Oct 2010 CTP bits
  7. Check out the cool WP7 client sample to synchronize your data from and Azure cloud service. This is a really great enabler for offline capable smart client applications

  8. Silverlight for Windows Phone 7 toolkit November
  9. New Components; AutoCompleteBox, ListPicker, LongListSelector, Page Transitions.
    Existing Components; GestureService/GestureListener, ContextMenu, DatePicker, TimePicker, ToggleSwitch, WrapPanel

  10. October 2010 update for WP7 Dev tools
  11. Includes: A new Windows Phone Capability Detection Tool, Windows Phone Connect Tool – connect your PC and phone without needing Zune running and Updated Bing Maps Silverlight Control – performance improvements to guesture controls

Enjoy,
Nick

Windows Phone 7 WebBrowser control Script Notify

Recently I was talking to someone who was just starting to look at implementing Push Notifications in one of their Windows Phone 7 applications – specifically for the Raw Notification functionality.

After a little bit of probing i found that the desired sequence that was intended to be used was along the following lines

  1. Application is used to customise an order
  2. WebBrowser Control used for taking payment
  3. Successful Payment must redirect to a succes page in the WebBrowser control
  4. Server to send Push notification – Raw so the application could acknowledge successful payment and transition the UI away from the WebBrowser control.

Now Push Notifications are indeed cool, I played around with them in the April CTP and created a Push Notification API and another post on how to receive notifications on the WP7 client (update for the current RTM in progress – more on this later). This took some time as it was early days for WP7 and there was not much documentation to create the first cut of the API. The main point to note here is it took time and adds an extra layer of complexity to your solution.

Now like any other tech decision as much as the uber cool, funky, and shiney factor seems to influence people its also important to consider – fit for use.
And as a result the scenario above was updated to use ScriptNotify of the WebBrowser control to remove the overhead of implementing Push Notifications – Raw. The updated sequence now becomes:

  1. Application is used to customise an order
  2. WebBrowser Control used for taking payment
  3. Successful Payment must redirect to a succes page in the WebBrowser control
  4. Success page uses javascript to perform a Notify to the WebBrowser control to transition the UI.

The following has been simplified to demonstrate the key code that required to do this:

  1. On the WebBrowser control set IsScriptEnabled to true and provide a handler for ScriptNotify
  2. <phone:WebBrowser IsScriptEnabled="True"  ScriptNotify="webBrowser_ScriptNotify" HorizontalAlignment="Left" Name="webBrowser"  VerticalAlignment="Top"/>
  3. handle the notify event in the code behind
  4.         private void webBrowser_ScriptNotify(object sender, NotifyEventArgs e)
            {
                int orderId = 0;
                int.TryParse(e.Value, out orderId);
    
                if(orderId > 0)
                    //TODO: transition
            }
  5. In the HTML of the success page that is redirected to in step 3 perform a JS notify as follows:
              window.external.notify("123")

Enjoy,

Nick

Windows Phone 7 HttpWebRequest returns same response from Cache

I hit an problem doing some dev on Windows Phone 7 several weeks back and have since helped a couple people out in the old windows phone 7 forum and LinkedIn Windows Phone 7 user group with the same thing.  This issue, is in fact, not an issue – it is more of a lack of knowledge that the HttpWebRequest and WebClient cache responses for your web request.  Let me tell you that client side caching is a good thing that will save you bandwidth and also speed up the percieved user experience when requesting the same resource.  So probably best to get straight to where problems can be faced. 

If you are performing a HttpWebRequest to a uri like so:

string someUri = "http://someservice/service/GetContent/userid/";
HttpWebRequest request = HttpWebRequest.CreateHttp(someUri);           Â
request.Accept = "application/json"; 

request.BeginGetResponse(OnGetSomeontentCallback, new GetSomeContentState(request, onResultAction));Â

Now lets pretend your service implementation has some smarts around what the user has seen historicaly and returns a different image each time you request the same uri.  You will find on your second call to the service that the same image is displayed in your app as the first call and then you might scratch your head *scratch*, check your service logic – all looks ok, set a breakpoint in your service and bang – the breakpoint is not being hit in the service on the second call and suddently is becomes clear the HttpWebRequest (and WebClient) for that matter will cache the response for that uri. 

So your faced with the following question – Should I change my service interface or change/remove the client side caching for this service operation?.   Well the answer is application specific and will fall into two categories:

1. Your client application knows what resource should be next

  • In this case you should alter your service interface to accept the Id of the item this way the result will be cached only for each specific item.

2. Your client has no idea what should be next as the server figures it out 

  • In this scenario i have identified 3 options – initialy i though you would be able to change the cache to expire or not cache on the HttpWebRequest instance but this is not in fact possible so you have to look at the uri and/or serverside.   Here are 3 options: 

Option 1: Add a random Query String to the end of your URI (think Guid.NewGuid()) this will avoid caching on the client as the Query String will be different each time

Option 2. Specify no cache in the OutgoingResponse header within your WCF service operation:


public ResultABC GetContent(string abc)
{
...
WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache");  //This line
...
return ...;
}

Option 3. markup your service operation with the AspNetCacheProfile attribute:

[AspNetCacheProfile("GetContent")]
public ResultABC GetContent(string abc)
{
...
...
return ...;
}

update your web.config


<system.web>
<caching>
     <outputCache enableOutputCache="true" />
     <outputCacheSettings>Â
        <outputCacheProfiles >Â
            <add name="GetContent" duration="0" noStore="true" location="Client" varyByParam="" enabled="true"/>Â
        </outputCacheProfiles>Â
    </outputCacheSettings>
</caching>
...
</system.web>

What did I choose:
Well all methods work to avoid the particular scenario given.  But in my case, the client application never knows what is next so I was forced to stop the client side cachingso the one I opted for was Option 3 as externalising this configuration means you can change at any later time without needing to rebuild and deploy your service.  

 If my client did know what the user was requesting then I would have gone for passing the ID in the uri to ensure that it is unique per each resource and that each resource would be cached on its unique uri.  Note here it is important for the ID to be passed on the URI it appears the URI forms the key for the cache i did see one example where the user was passing the ID in the Header collection e.g wc.Header["ID"] = id; and this was exhibiting the same problem.  Moving the ID to the URI solves the problem.

Hope this has been helpful,

Nick

 

I Won a Windows Phone 7 at PDC Replay

Hi there readers,

Last night i was at The SAUG  I was thinking about how far away the dream of owning one of these Windows Phone 7 devices would be especially since i had resigned from my job almost three months ago, sacraficing my salary to embark on a dream Development Adventure  that utilisies some of the techonologies I have been blogging about over the past few months – Azure, Windows Phone 7 and ASP .NET MVC 2 + 3(beta)

This is particularly great news and i am still quite excited so here it is  - I am now the happy new owner of a Windows Phone 7 – its just not delivered yet and in my excitement I forgot to ask which Model it was going to be. I haven’t had a chance to play with the hardware although have heard good things - I am really hoping it will be a HTC or Samsung model – but I guess I will see what comes :) .

A big thanks to Microsoft and their PDC replay event this morning at 9am and a very special thanks to Andrew Coates who asked the question about Windows Phone 7 that managed to win me this device :) .  I would list the Q&A but there is another replay session occuring now so dont want to spoil it of anyone.

Nick :) :) :)

Windows Phone Developer Tools October 2010 Update

The Windows Phone Developer Tools October 2010 Update includes:
  • Windows Phone Capability Detection Tool – Detects the phone capabilities used by your application. When you submit your application to Windows Phone Marketplace , Microsoft performs a code analysis to detect the phone capabilities required by your application and then replaces the list of capabilities in the application manifest with the result of this detection process. This tool performs the same detection process and allows you to test your application using the same list of phone capabilities generated during the certification process. For more information, see How to: Use the Capability Detection Tool.
  • Windows Phone Connect Tool – Allows you to connect your phone to a PC when Zune® software is not running and debug applications that use media APIs. For more information, see How to: Use the Connect Tool.
  •  Updated Bing Maps Silverlight Control – Includes improvements to gesture performance when using Bingâ„¢ Maps Silverlight® Control.

Download Here