Updated NotificationsExtensions WnsRecipe Nuget to support Windows 8.1 templates now available

A short post to let you know that I have just published the updated NotificationsExtensions WnsRecipe Nuget with support for the new notification templates that were added in Windows 8.1.

Here is a short demonstration of how to use it to send a new TileSquare310x310ImageAndText01 template with the WnsRecipe Nuget Package

Install the package using Nuget Package Manager Console. (Note you could also do this using Manage package references in solution explorer)

install-package WnsRecipe

Add using statements to the NotificationsExtensions namespace

using NotificationsExtensions;
using NotificationsExtensions.TileContent;

New up a new WnsAccessTokenProvider and provide it your credentials configured in the Windows Store app Dashboard

private WnsAccessTokenProvider _tokenProvider = new WnsAccessTokenProvider("ms-app://", "");

Use Tile Content Factory to create your tile template

var tile = TileContentFactory.CreateTileSquare310x310ImageAndText01();

tile.Image.Src = "https://nickha.blob.core.windows.net/tiles/empty310x310.png";
tile.Image.Alt = "Images";
tile.TextCaptionWrap.Text = "New Windows 8.1 Tile Template 310x310";

// Note you really should not do the line below :), 
// instead you should be setting the required content 
// through property tile.Wide310x150Content so that users
// get updates irrespective of what size tile they have pinned to Start
tile.RequireWide310x150Content = false;  

//Send the notification to the desired channel
var result = tile.Send(new Uri(channel), _tokenProvider);

and here is the output
310x310tile

Enjoy, Nick Harris

Blog Series: Sending Windows 8 Push Notifications using Windows Azure Mobile Services

Sending Windows 8 Push Notifications using Windows Azure Mobile Services

Recently we announced the preview of Windows Azure Mobile Services. In this blog series I will detail how to build a Windows Azure Mobile Service to send push notifications of varying types to your Windows 8 applications.

This series will walk through creating a push notification scenario using WNS and Windows Azure Mobile Services.

As I post each part I will update the links below and tweet as the post is available. So lets get started with Part 1 – Azure Mobile Services and Push Notifications an Overview

Part 1: Windows Azure Mobile Services and Push Notifications an Overview

What is Windows Azure Mobile Services?

Here is an info-graphic on the current Windows Azure Mobile Services stack I pulled together as part of a presentation I recently gave at TechEd.  It’s important to note that this info-graphic captures Mobile Services today and over time you will see the feature set of Mobile Services grow exponentially with subsequent releases.

 

 

 

 

 

 

 

 

 

 

The goal of Windows Azure Mobile Services is to make it incredibly easy for developers to add a cloud backend to their client apps be it a Windows 8, Windows Phone, iOS or Android application. To do this we provide a number of turn key features baked right into the Mobile Services experience. As the diagram depicts Mobile Services today provides:

  • Structured Storage
    • ability to store structured data to a SQL Database using dynamic schema without being concerned with writing underlying T-SQL.
    • If using single database apps are automatically partitioned by schema e.g AppX.Todoitem, AppY.Todoitem
    • If you want access to your data you are not locked out and can manage it in a number of ways including the Mobile Service Portal, SQL Portal, SQL Management Studio, REST API etc.
  • Server Logic
    • Service API: Mobile services automatically generates a REST API to allow you to perform CRUD operations from your client application on your structured storage
    • With Dynamic Schema (enabled by default), your Mobile Service will automatically add columns to tables as necessary to store incoming data.
    • Ability to author server side business logic directly in the portal that is executed directly within the CRUD operation pipeline
  • Auth
    • Makes it easy for your users to Authenticate against Windows Live. Other major identity providers are coming soon.
    • The REST API can be locked down using table level permissions using a simple drop down.  No complex code required.  Available permissions levels include: Everyone, Anyone with an Application Key, Only Authenticated Users, Only Scripts and Admins.  These permissions can be set individually on each table and can granularly control each CRUD operation of each table.
    • More granular control can be added using server side scripts and the user object
  • Push Notifications
    • Integrates with WNS to provide Toast, Tile and Badge Notifications.
    • WNS auth is made easy with the portal captures your WNS client secret and package SID
    • the server side script push.wns.* namespace  performs WNS auth for you and provides a clean and easy object model to compose notifications
  • Common tenants of Windows Azure Services
    • Scale
      • Compute – scale between shared and reserved mode, increase/decrease your instance count
      • Storage – ability to scale out your mobile service tenant(s) to a dedicated SQL DB. Ability to scale up your SQL DB from web through business to 150GB.
    • Diagnostics
      • View diagnostics directly in the portal including API calls, CPU time and Data Out
    • Logging
      • Console.* operations like console.log and console.error provide an easy means to debug your server side scripts.

Today we provide client libraries for Windows 8 to make consuming mobile services easy.  For more details on what client libraries (Windows 8, Windows Phone, iOS and Android) are supported at the time of reading please see: Mobile Services and Mobile Service Reference.

What are Push Notifications?

The Windows Push Notification Services (WNS) enables you to send toast, tile, badge and raw notifications from the cloud to your Windows Store applications even when your app is not running. Push notifications are ideal for scenarios when you need to target a specific user with personalized content.

The following diagram depicts the general Lifecycle of a push notifications via the Windows Azure Notification Service (WNS).  We’ll walk through the steps shortly but before doing so I thought it would be important to call out that as a developer implementing a push notification scenario all you need to do is implement those interactions in grey and the applications/services in blue.  Fortunately Mobile Services makes a great deal of this easy for you as you will see throughout the reset of this series. 

The process of sending a push notification boils down to three basic steps:

  • 1. Request a channel. Utilize the WinRT API to request a Channel Uri from WNS.  The Channel Uri will be the unique identifier you use to send notifications to your application.
  • 2. Register the channel with your Windows Azure Mobile Service.  Once you have your channel you can then store your channel and associate it with any application specific data (e.g user profiles and such) until your services decide that it’s time to send a notification to the given channel.
  • 3. Authenticate and Push Notification to WNS. To send notifications to your channel URI you are first required to Authenticate against WNS using OAuth2 to retrieve a token to be used for each subsequent notification that you push to WNS once you have this you can compose and push the notification to the channel recipient. The push.wns.* methods make this task exceptionally quick to accomplish compared to writing it all from scratch yourself.

All in all Windows Azure Mobile Services makes all these concepts and steps and incredibly simple to implement though its structured storage and push notifications features.  This series will walk through creating a push notification scenario using WNS and Windows Azure Mobile Services.

As I post each part I will update the links below and tweet as the post is available

Enjoy,

Nick

Building Connected Windows 8 Apps with Windows Azure

Hey – I thought I would share this video, deck and completed demo for all of you who attended my TechEd North America + Europe sessions

Are you building a connected Windows Metro style app? This session introduces you to Windows Azure and demonstrates how you can build connected experiences for your Windows 8 Metro style apps. After walking the through the fundamentals of both platforms, we take a deep dive as we demonstrate how you can use Windows Azure to support common geo-location, multimedia, data and push notification scenarios. At the end of this session, you will be empowered to begin building and deploying your own Windows 8 client applications that are powered by Windows Azure

You can download the full video in high res from channel 9 here

Download the deck Here
Download the source Here Note I have removed the connection strings for SQL + Windows Azure storage + Bing Maps. You will find all places that you need to replace these by doing a search for TODO-REPLACE. Enjoy!

Kind Regards,
Nick

Sending Language specific Push Notifications to Windows 8 using the WnsRecipe

I was recently asked to help out with a MSDN forum post on how the WnsRecipe NuGet package can be used to send Push Notifications via WNS to Windows 8 Metro app clients.  Essentially here are the steps.

Note: This post assumes you have already created a client app, requested test credentials for WNS and received a notification channel in your cloud service.  If you have not yet done this I would recommend you watch this episode of cloud cover where I demonstrate the setup:

If you want to download the hi def version here is the direct link to Channel 9 for this episode .

Now that you have watched the pre-req the rest is really quite simple.

Install the WnsRecipe NuGet into your solution using the NuGet Package Manager

  • Right click on your project and select ‘Manage NuGet Packages’
  • Select Online and search for WnsRecipe and press Install
    using NotificationsExtensions; 
    using NotificationsExtensions.TileContent;
    
  • Use the recipe as per normal but recall to set the appropriate BCP 47 language code  for your wideTile.Lang and squareTile.Lang properties
    //new up an access token provider with your credentials
    IAccessTokenProvider tokenProvider = new WnsAccessTokenProvider("<your package sid>", "<your client secret>");     
    var uri = new Uri("<your endpoint uri>");
    
    //Create the wide tile
    ITileWideText09 wideTile = TileContentFactory.CreateTileWideText09();     
    wideTile.Lang = "de-DE";     
    wideTile.TextHeading.Text = "Test-Paket";     
    wideTile.TextBodyWrap.Text = "ä";
    
    // new up a square tile to send down with the wide tile
    // as you do not know if the user has pinned the tile to small or wide
    ITileSquareText02 squareTile = TileContentFactory.CreateTileSquareText02();     
    squareTile.Lang = "de-DE";     
    squareTile.TextHeading.Text = "Test-Paket";     
    squareTile.TextBodyWrap.Text = "ä";     
    
    // set the square tile content
    wideTile.SquareContent = squareTile;
    
    //Send notification - note you should pay attention to the Status codes coming back from the 
    //send operation in the result variable.
    var result = wideTile.Send(uri, tokenProvider);
    
  • And that’s basically it as mentioned above this is a somewhat fragment sample. Please do watch the Cloud Cover episode if you require more detail

For a full list with screenshots of the different tile template types please see this MSDN reference

Updated Windows Azure Toolkit for Windows 8 Consumer Preview

On Friday we released the an update to the Windows Azure Toolkit for Windows 8 Consumer Preview. This version of the toolkit adds a Service Bus sample, Raw Notification sample and Diagnostics to the WnsRecipe NuGet. You can download the self-extracting package on Codeplex from here.

If you are building Windows 8 Metro Style applications with Windows Azure and have not yet downloaded the toolkit I would encourage you to do so.  Why?, as a quick demonstration the following video shows how you can use the toolkit to build a Windows 8 Metro Style application that uses Windows Azure and the Windows Push Notification Service (WNS) to send Toast, Tile and Badge notifications to your Windows 8 Consumer Preview apps in under 4 minutes.


You can view/download the hi-def version of the video on channel 9 here

What’s in it?

  • Automated Install – Scripted install of all dependencies including Visual Studio 2010 Express and the Windows Azure SDK on Windows 8 Consumer Preview.
  • Project Templates – Client project templates for Windows 8 Metro Style apps in Dev 11 for both XAML/C# and HTML5/JS with a supporting server-side Windows Azure Project for Visual Studio 2010.
  • NuGet Packages – Throughout the development of the project templates we have extracted the functionality into NuGet Packages for example the WNSRecipe NuGet provides a simple managed API for authenticating against WNS, constructing notification payloads and posting the notification to WNS. This reduces the effort to send a Toast, Tile, Badge or Raw notification to about three lines of code. You can find a full list of the other packages created support Push Notifications and the sample ACS scenarios here and full source in the toolkit under /Libraries.
  • Samples  – Five sample applications demonstrating different ways Windows 8 Metro Style apps can use Push Notifications, ACS and Service Bus
  • Documentation – Extensive documentation including install, file new project walkthrough, samples and deployment to Windows Azure.

Want More?

If you would like to learn more about the Windows Push Notification Service and the Windows Azure Toolkit for Windows 8 check out the following videos.

Building Metro Style apps that use Windows Azure Service Bus

You can view/download the hi-def version of the video on channel 9 here

Sending Push Notifications to Windows 8 and Windows Phone 7 Devices using Windows Azure

You can view/download the hi-def version of the video on channel 9 here

Building Metro Style apps that use Push Notifications

You can view/download the hi-def version of the video on channel 9 here

Building Metro Style apps that use the Access Control Service

You can view/download the hi-def version of the video on channel 9 here

For more details, please refer to the following posts:

Please ping me on twitter to let me know if you have any feedback or questions @cloudnick

Enjoy,
Nick

Delivering Toast Tile and Badge Notifications to Windows 8 and Windows Phone using Windows Azure

Here is a recent talk I gave at TechDays Belgium.

Notifications extend the reach of your app to the desktop and device, but with a large user base timely delivery can be challenging without the right tools. In this session we’ll review the notification options available to Windows Phone and Windows Metro Style apps, demonstrate how you can deliver notifications using Windows Azure, and discuss features provided by Windows Azure to scale your notification solution. By the end of this session you will understand how to use Windows Azure to rapidly develop a notification enabled service for Windows Phone and Windows 8 apps.

or watch direct from channel 9

Enjoy,
Nick