Monday 11 June 2012

Windows 8 Metro MVVM Light Push Notification Fix

I'm working on a WP7 port to Windows 8 and got to the push notifications section. I'd been struggling to get notifications to work. Mike Taulty kindly helped me out with this: http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2012/06/08/windows-8-metro-style-app-simple-wns-push-notification.aspx to test notifications without Azure. My MVVM Light app wouldn't respond and I was getting 403 - Forbidden responses from the WNS server. I suspected there may be something wrong with my app so I built a bog standard "Hello Windows 8" app which worked nicely, so it proved that there was something wrong with my app!


I figures it would be something wrong with an ID or something similar because I know in WP7 MVVM Light projects the app GUID in the manifest is always the same which causes apps to be overwritten on deployment. There is no ID in the manifest so I had a look at the pfx file and it's got Laurent's id on it. So this is what I did:


1. Copied the pfx from "Hello Windows 8" app to my MVVM Light app and renamed it.


2. Edited the MVVMLightProject.csproj and changed the name and thumbprint of the pfx to that of "Hello Windows 8"



    <DefaultLanguage>en-US</DefaultLanguage>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-XXXXXXXXXX};{FAE04EC0-301F-11D3-BF4B-XXXXXXXXXX}</ProjectTypeGuids>
    <PackageCertificateKeyFile>XXXX_TemporaryKey.pfx</PackageCertificateKeyFile>
    <PackageCertificateThumbprint>E31B6A298677237928A520954AF2FXXXXXXXXXX</PackageCertificateThumbprint>
    <ExpressionBlendVersion>5.0.30129.0</ExpressionBlendVersion>
  </PropertyGroup>


3. Launched my app and grabbed the channel URI from the output window (noticed it was slightly longer than before) and put it into Mike's app along with the other API info and....


4. It worked!