This was my recent session at the virtual tech days, a online event from Microsoft India : http://bit.ly/q4AFzZ
Please see the demo source code and the PowerPoint decks from here : http://bit.ly/nf7Uld
The below was the agenda.
STEP1 : The story of Windows Azure & Devices
I set context as to what is Windows Azure in terms of providing large pool of resources (tending to infinity) and completely accessible through REST based http call and this makes it completely accessible by variety of devices , tools and languages.
To gain context about windows azure , read on here : http://bit.ly/nY2z22 & to understand the synergy between azure & phone, a wonderful article in MSDN is here : http://bit.ly/mSbC8c
STEP 2 : What is Microsoft Push notification Service
Next was to set context about Microsoft Push Notification Service. Check here to understand the basics of of this , the whys , what’s & how’s : http://bit.ly/o7o25H
The scenario is very straightforward -If we have a twitter app on a device (lets call it the phone), and we want to be notified of new tweets. We have the below options:
The above 2 options are very expensive on battery life of the device. The option is to have a 3rd party service pushing these notification to a centralized agent on the phone and the agent, then transmits the notification in various visual feels.
So i mean by this is there are 3 components here
So below are the process steps
Boxes in grey are components already available and boxes in orange are the code that developers need tow rite
Finally, these notifications can be of 3 types
STEP 3 : File – New Demo
Setting up a demo needs the following components
Before we start taking a look at the code and steps , let me get the list of all development tools that we need to have in place
We will create a WCF Service on the cloud. To have any device or phone application, we surely need a service that it can get notifications and data from. So let us create a cloud project and choose WCF web role as template and add the below as operation contracts
void SubscribeMyPhone(Guid phoneId, string ChannelURI);
void PushRawData(string rawMessage);
void PushToast(string toastTitle, string toastMessage);
void PushTileUpdate(string tileTitle, int tileCount, string tileImageURI);
We need implement these methods and please take a look at the PushNotSample in the attached sample.zip file here : http://bit.ly/nf7Uld
Next we need deploy this application to the windows azure data centre from Visual Studio 2010 . Please check on this article that gives all the details of the steps to publish your application to the azure data centre from Visual Studio 2010 : http://bit.ly/p3ey2x
Next is to create a client application, for the sake of the demo, we will use Windows Phone application.
Please see the below snapshots of the Phone emulate just when the application is launched and after the Subscribed & ChannelURI is got.
Finally look at the PushClient sample in the source code located in the sample.zip at http://bit.ly/nf7Uld
Testing the Application
The last part of the demo is really about running this application and seeing everything in action.
That’s it!!! You now have a basic windows phone application, that can receive notifications from a WCF service hosted on Windows Azure Web role through the Windows Push Notification Service.
Happy Coding !