Getting to know the Identity of your Windows Phone 7 Application

Getting to know the Identity of your Windows Phone 7 Application

There are a number of reasons why you might want to know the identity of someone using your application. Most revolve around the need to store and track personalised information and to be able to uniquely identify any individual user. In your Windows Phone 7 application there are actually three different identities that you may be interested in:

User Id

In order to get the most out of their Windows Phone 7 device (including being able to access marketplace in order to download and install applications and games) a user will need to sign in with a Windows Live Id (or an XBox Live gamer tag). From your application you are able to retrieve a unique identifier that can be used to identify this user. If the same user uses the same Windows Live Id to sign into two different Windows Phone 7 devices and runs your application, the application will see the same identifier. If the same user uses two different Windows Live Ids, then your application will see two different identifiers.

Note that I use the word “identifier”, this is intentional as what you get back doesn’t include any profile information (not even their actual live id) about the user. The following code extracts the 32 character anonymous identifier (ANID) from the UserExtendedProperties class.

private const int IdentifierLength = 32;
private const int IdentifierOffset = 2;

public static string UserId()
{
    object anid;
    if (UserExtendedProperties.TryGetValue("ANID", out anid))
    {
        if (anid != null && anid.ToString().Length >= (IdentifierLength + IdentifierOffset))
        {
            return anid.ToString().Substring(IdentifierOffset, IdentifierLength);
        }
    }

    return null;
}

Note: To access properties in the UserExtendedProperties class you need to demand the ID_CAP_IDENTITY_USER capability in the WMAppManifest file for your application.

Device Id

Alternatively, you may want to identify each device that your application is being run on (this will help resolve the situation where a single user signs into two devices with the same Windows Live Id). This is done using the DeviceUniqueId property from the DeviceExtendedProperties class.

public static byte[] DeviceId()
{
    object uniqueId;
    if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId)){
        return (byte[])uniqueId;
    }

    return null;
}

Note: To access the DeviceUniqueId property you need to demand the ID_CAP_IDENTITY_DEVICE capability in the WMAppManifest file for your application.

Application Id

There are certain cases where you will want to be able to uniquely identify the application (for example, if you write a user control, or a reusable library you might want to be able to identify applications where they are being used). The easiest way to uniquely identify the application is via the ProductID attribute in the WMAppManifest.xml file.  eg

<?xml version="1.0" encoding="utf-8"?>
  <Deployment >http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
    <App >image

Having to manually extract the ProductID this way is somewhat tedious and from a user control/library developer perspective not very reliable (a developer could pass in the same ProductID for all their applications and thus only pay once). An alternative is to access the WMAppManifest.xml file that gets deployed with the application. When you compile your application it generates a .xap file. This is little more than a compressed file (try changing the extension to .zip and extract the contents) which is expanded into a folder on a Windows Phone 7 device when it is installed. To read the contents of the WMAppManifest.xml file all you need to do is open it the same way as you would any other content that has been packaged with your application.

public static Guid ApplicationId() {
                using(var strm = TitleContainer.OpenStream("WMAppManifest.xml"))
                {
                    var xml = XElement.Load(strm);
                    var prodId = (from app in xml.Descendants("App")
                                  select app.Attribute("ProductID").Value).FirstOrDefault();
                    if (string.IsNullOrEmpty(prodId)) return Guid.Empty;
                    return new Guid(prodId);
                }
        }

That was relatively straight forward…. oh, don’t forget to add a reference to the Microsoft.XNA.Framework assembly which includes the TitleContainer class.

 

The following screenshot shows the results for each of these identifiers. Note that because this is from the emulator where there is no signed in user, the User Id is null/empty.

image

Where’s my Pink Windows Phone 7?

Where’s my Pink Windows Phone 7?

It would appear that Apple, Google and Microsoft have been so intently focussed on competing to build the best phone operating system they’ve forgotten that a large proportion of the phone sales are based on the look of the phone rather than functionality. For example, take a look at a selection of the Windows Phone devices that are now available on the market. One word….. BORING….. actually a second word comes to mind….. GEEK. That’s right, the designs are boring, lack imagination and a for a predominantly technical male audience.

image

Now before you think that I’m having a go at Windows Phone, if you take a look at the Android devices available they’re no better (in fact most look similar to the above which is no surprise since they’re mostly by the same set of device manufacturers). Apple is slightly different in that they at least employ decent industrial designers. If you look at the iPhone 3 design (white and black) they had sex appeal to a design conscious audience, and surprise surprise it worked. They had lust appeal and your average consumer wanted one, often without knowing why.

In my mind the iPhone 4 takes a somewhat different take. Whilst not being a sexy as previous devices, the unique look at feel that Apple has created, and the return to a metal shell, appeals to a more corporate user (no surprise as Apple tackles the enterprise space, fighting RIM and Microsoft for control of the corporate users).

So, what’s missing? Well I think that there are two audiences that are being missed. Firstly the “Pink” market – 15-25 year old predominantly female market – that want a phone that has bright colours and is easily identifiably theirs. Take for example my PS3 controller….. it’s bright pink and I know it’s mine!

image

The second market is what I’ll call the “Accessory” market – those users who want to change the shell of their phone and hang attachments/accessories off them. Both Android and Windows Phone devices lag behind the iphone market in the number of accessories available for them (eg docking stations, speakers, protective covers, credit card sleaves). However, this is nothing compared to the Nokia market. Next time you’re in a Westfields or other large shopping centre, look out for the mobile phone accessory counter (there is sure to be one). So many accessories, mostly for the feature phones by Nokia, Motorola etc.

Whilst I think that Windows Phone 7 is an awesome platform there is no sex-appeal to the hardware. Given the number of different manufacturers making devices, I’m surprised by the complete lack of imagination…. give me a pink Windows Phone.

Some Advice on the Windows Phone 7 AppHub

Some Advice on the Windows Phone 7 AppHub

The submission process for Windows Phone 7 applications into the Marketplace is done via the AppHub and there are some interesting quirks that you may come across or have to work around. Here are just a few hints to get you started:

Registration: Register for the AppHub today. Yes I know if costs money but if you’re going to be releasing something via marketplace you’re going to need an account eventually. It’s best to get this process done as early as possible to avoid delays when you’re app is ready to submit.

Free Applications: If you going to submit free app be aware that you get 5 free submissions. If your application fails to pass certification that will count as a submission (so if you succeed the second time around you’ve used 2 of your 5 free submissions). For free apps, make the first submission the equivalent of Hello World (ie so simple that it can’t possibly fail) but DO NOT check the box at the end of the submission process that will automatically publish your application after certification. Once your application has passed certification all further updates to that app are free – now you can add all the real functionality, fails as often as you like, and not have to worry about using any more of your free submissions. When you’ve certified a version of your application that you’re happy with, then you can choose to publish it.

Updates: Every time you want to update your application you need to complete the entire submission process again (including uploading all the artwork, descriptions, keywords etc). To make this process easier, each time you publish your application, immediately start a new application update and copy all the existing values from the current application into the new submission. Then, when you do decide to update the application, you can quite easily change the xap file in the new submission and send it off for testing. I can’t urge you enough to double-check all values in the new submission to make sure they are correct….. the last thing you want is for your application to be listed as a game…..

Reviews: There is currently no way to provide feedback to users who have provided a review of your application. However, you, as the author, can download your own application and provide a review that responds to any feedback or comments from other users. You might want to annotate the review with “authors comment” or words to that effect to indicate that you are the author (don’t forget to rate your application of course – how many stars do you think it deserves?)

Windows Phone 7 WebBrowser and WebBrowser Control Site Formatting

Windows Phone 7 WebBrowser and WebBrowser Control Site Formatting

Today I found myself revisiting a problem I encountered a few months back whilst trying to get a website to correctly render on a Windows Phone 7 device. There are a few pages that discuss how to do this through the user of the viewport meta tag:

http://blogs.msdn.com/b/iemobile/archive/2010/11/22/the-ie-mobile-viewport-on-windows-phone-7.aspx

http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/bcd032d5-da02-4875-a74f-98db0f95dc89

http://www.ben.geek.nz/2010/07/integrated-links-and-styling-for-windows-phone-7-webbrowser-control/

http://technodave.wordpress.com/2010/11/11/moving-files-from-xap-to-isolated-storage-for-local-html-content-on-windows-phone-7/

http://learnthemobileweb.com/2009/07/mobile-meta-tags/

http://msdn.microsoft.com/en-us/library/ff462082(VS.92).aspx

Following these posts it would be easy to come up with a viewport meta tag that look like the following (or you could set the width property of the viewport meta tag to device-width, depending on the size of your content)

<meta name="viewport" content="width=208;height=377;user-scalable=no" />

This will NOT work, where as the following will work nicely….. spot the difference?

<meta name="viewport" content="width=208,height=377, user-scalable=no" />

Yes, that’s right you must separate the values with COMMAS not semi-colons (even that works on most other mobile platforms such as the iphone). Repeating that…. separate the name-value pairs in the content attribute of the meta tag with commas.

LG Optimus 7: Up and running in 5 minutes

LG Optimus 7: Up and running in 5 minutes

For those of you who know me you’ll probably be aware that nearly everything I use daily is stored in the cloud somewhere – my email on a hosted exchange server, most of my current work via live mesh and most source code for projects is in subversion. This means that I can literally pick up a new device and be up and running in a matter of minutes. Over the past couple of months I’ve become quite skilled in setting up a Windows Phone 7 device with all my basic information to get me back up and running (it takes a little longer to remember which apps I had installed and then to locate and install them via the Marketplace client on the device). So much so, that the other day I reset my device and had it up and running again on a short taxi ride from the Sydney CBD to Luna park.

Anyhow enough about that…. this post is about the brand new LG Optimus 7 that arrived on my desk. Here are the steps I went through to get this device up and running with my main accounts (so that I’m operational with it).

DSC02082DSC02084

The Box: Yeh I know, not particularly interesting. What is nice is that they haven’t stuck with the same “Windows Phone 7” box that all the other OEMs seem to be using. This box is slightly wider giving everything a little bit more room (note that one of the Windows Phone design principles is around “clean and open” ie not cluttered)

DSC02087DSC02088

The Bits: Ok, the usual bits are all there – headphones with integrated microphone (check), micro-usb cable (check), power plug (check), info booklet (check). The second image shows the LG Optimus 7 with the back cover removed and the battery and my SIM card waiting to be inserted.

DSC02093DSC02092

Power On: LG welcome screen followed by a prompt to change language (thankfully as I can’t read the default)

DSC02094DSC02095DSC02100

Time and Date: After a reboot you’re prompted to enter the timezone, date and time. Once configured you receive your first welcome message – note the brilliant Red theme colour that is the default.

DSC02102DSC02103DSC02104

Connectivity and Region Settings: Unfortunately during the initial setup I couldn’t enter my Windows Live Id as I was neither on my secure WiFi network, nor on 3G. The latter is because my stupid telco (ie Virgin Mobile) haven’t configured their settings so that the APN is picked up automatically. This is easily resolved by going to Settings and configuring both my WiFi and Cellular settings (note that to set the APN you need to hit the edit apn button at the very bottom of the Cellular settings area). When you set the region/language, make sure you tap the “accept changes and restart” link – unlike all other Settings which auto-save, this setting requires you to restart.

DSC02105DSC02107DSC02108

Accounts: From left to right I entered my Windows Live Id, Outlook and Facebook details. Each time go to Settings –> Email & Accounts and select the type of account you want to add.

DSC02109

We’re Done: When I return to the Start screen the People tile is already being updated with images from my list of contacts.

All that in under 5 minutes. Try doing that on any other platform.

 

Disclaimer: I’ve been provided with an LG Optimus 7 by LG in order to review the device.

Windows Phone 7 Competition time with LG

Windows Phone 7 Competition time with LG

This is a heads-up that we’re going to be running a competition in the coming weeks to win a brand new Windows Phone 7 LG Optimus 7. Get Visual Studio and Expression Blend started and be ready to put your development skills to the test. More details to come in the next couple of days…..

Free versus Trial Windows Phone 7 Applications

Free versus Trial Windows Phone 7 Applications

Oren Nachman has clarified some of the confusion surrounding free applications on the Windows Phone 7 marketplace in his post WP7 Marketplace Tip #2.5 – Free App + Updates Policy Clarified (finally). Ok, so the upshot is that you have 5 submissions for free apps but unlimited paid apps. So you might be thinking…. but I have a ton of ideas that I want to build free apps (that make money via ads or subscriptions etc). The trick here is that Windows Phone 7 applications support trial mode.

As a developer it’s completely up to you as to what you do in trial mode – the typical things are to limit functionality or time limit the application. But if you’re creating an application that you want to be free, just submit it as a paid application with trial mode enabled (an option when you submit your “paid” application). Simply completely ignore this flag and just allow users to use the full functionality of your “free” application. Of course if users decide to pay you for the application then you’ll get that too (win win all around if you ask me, of except Microsoft who won’t make their 30% unless users purchase your application).