32
Sending Push Notifications to Windows 8 and Windows Phone 8 devices using Windows Azure Email : [email protected] Twitter : @abhi2434 Websites: http://www.abhisheksur.com http://www.dailydotnettips.com Community : KolkataGeeks http://www.kolkatageeks.com Abhish ek Sur

Employing push technology on devices and phones with azure mobile services

Embed Size (px)

DESCRIPTION

Push technology is the future. When you are using your devices, pushing messages are an important concern that you would be using. With Cloud integration and Azure Mobile services, implementing push based service is damn easy. The presentation will give you best of knowledege about Push technology in all the devices and make a Azure integration to that. You can download the full session Video here : https://msevents.microsoft.com/CUI/EventDetail.aspx?culture=en-IN&EventID=1032561531&CountryCode=IN

Citation preview

Page 1: Employing push technology on devices and phones with azure mobile services

Sending Push Notifications to Windows 8 and Windows Phone 8 devices using Windows Azure

Email : [email protected] : @abhi2434Websites: http://www.abhisheksur.com

http://www.dailydotnettips.com

Community : KolkataGeeks http://www.kolkatageeks.com

Abhishek Sur

Page 2: Employing push technology on devices and phones with azure mobile services

Session Contents

What is Push Technology and why it is important?

Live Tiles and Notifications

Deep dive on using Windows Push Notification Service

Introduction to Windows Azure toolkit for Windows and Windows Phone

Building Apps using Azure Mobile Services

Page 3: Employing push technology on devices and phones with azure mobile services

Difference between Push and PullPull Technology

• Pull Technology states a scenario where the request is sent from the client for which a response is pulled from the server.

• Pull based communication do not require any handshake and virtually can initiate the authentication from client itself.

• Example : HTTP Requests.

Push Technology

• Push technology states a scenario where during an internet communication, the initial request is initiated by the server.

• Push Technology requires an initial handshake, to ensure the server opens up a channel for the specified client after authentication

• Example : WNS (Windows Push Notification Service)

Page 4: Employing push technology on devices and phones with azure mobile services

Windows 8 Live Tiles with Push Notifications

Page 5: Employing push technology on devices and phones with azure mobile services

Types of Tiles

Tile Notification

Updates Live Tiles with animated content which stays for a long time before the next update.

Badge Notification

Updates the Live tile with a number, indicating number of Badges received

Toast Notification

Gives a Toast notification is a flying alert that stays for 30 seconds after it is invoked.

Page 6: Employing push technology on devices and phones with azure mobile services
Page 7: Employing push technology on devices and phones with azure mobile services

Windows Push Notification Service (WNS)

Page 8: Employing push technology on devices and phones with azure mobile services

Push Notification Overview

1. Request Channel URI

2. Register with your Cloud Service

3. Authenticate & Push Notification

Windows 8

(1)

(2)

(3)

(3)

Page 9: Employing push technology on devices and phones with azure mobile services

1. Request a Channel URI

Each tile has a unique Channel URI

Requested by App on each run. URI can change

Generated by WNS

Opaque to the app

Windows 8

(1)

(2)

(3)

(3)

Page 10: Employing push technology on devices and phones with azure mobile services

Create WNS Notification Server

1. Upload the Application to the Windows App Store.

http://go.microsoft.com/fwlink/p/?linkid=234306

2. Reserve the App Name.

3. Add Push notification Live Services for the app

4. Change the Identity for the App from Appmanifest.

5. Get the package Security identifier and Client Secret

Walkthrough (http://msdn.microsoft.com/en-us/library/windows/apps/hh465407.aspx)

Page 11: Employing push technology on devices and phones with azure mobile services

2. Register with Your Cloud Service

Register your app with your own Cloud ServiceShould be authenticated and secure

Store Channel URI and associate it with any app specific context

Create your business logic for sending notifications

Windows 8

(1)

(2)

Page 12: Employing push technology on devices and phones with azure mobile services

Create WNS Notification Client

1. Create a Channel URI for the particular APP for handshaking.

2. Send the URI to the server for Unique identification of the Client.

3. Server keeps track to all the URI sent from the Client

4. Server requests the Live services with the unique URI to Push data to the client

channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

Page 13: Employing push technology on devices and phones with azure mobile services

3. Authenticate & Send Notification

OAuth 2 Authentication

HTTP POST to Channel URI

XML notification payload

Windows 8

(2)

(3)

(3)

Page 14: Employing push technology on devices and phones with azure mobile services

Demo

Page 15: Employing push technology on devices and phones with azure mobile services

3. Push Notification Code

using Windows.Recipes.Push.Notifications;

var toast = new ToastNotification(_tokenProvider);toast.ChannelUrl = "https://db3.notify.windows.com/?token=AQI8iP%2OtQE%3d";

toast.ToastType = ToastType.ToastImageAndText02;

toast.Image = "https://demosa.blob.core.windows.net/toastImg1.png";

toast.Text = new List<string> {"Miguel Saenz comment on your status", "I love that quote! How have you …"};

NotificationSendResult result = toast.Send();

Page 16: Employing push technology on devices and phones with azure mobile services

Push Notification Summary

1. Request Channel URI

2. Register with your Cloud Service

3. Authenticate & Push Notification

Windows 8

(1)

(2)

(3)

(3)

Page 17: Employing push technology on devices and phones with azure mobile services

What a service needs to support

How do I do that with Windows Azure?

Page 18: Employing push technology on devices and phones with azure mobile services

Demo

Page 19: Employing push technology on devices and phones with azure mobile services

Push Notifications

Windows Phone

Page 20: Employing push technology on devices and phones with azure mobile services

Push Notification in Windows Phone

1. Request Channel URI

2. Register with your Cloud Service

3. Authenticate & Push Notification

Windows Phone

(1)

(2)

(3)

(3)

Page 21: Employing push technology on devices and phones with azure mobile services

Windows Phone Toast

Title. A boldface string that displays immediately after the application icon. This is defined as the Text1 property in the XML schema.

Content. A non-boldface string that displays immediately after the Title. This is defined as the Text2 property in the XML schema.

Parameter. A parameter value that is not displayed but passed to your application if the user taps on the toast. This parameter can indicate what page the application should launch to. It can also contain name-value pairs to pass to the application. This is defined as the Param property in the XML schema

Page 22: Employing push technology on devices and phones with azure mobile services

Window Phone Tile - Front

Title. A string indicating the title of the application. The Title must fit on a single line of text and should not be wider than the actual Tile. Approximately 15 characters will fit in the title before being truncated.

BackgroundImage. An image displayed on the front of the Tile. Recommend that you always have a background image on the front of the Tile.

Count (also known as Badge). An integer value from 1 to 99. If the value of Count is not set or it is set to 0, the circle image and value will not display in the Tile.

Page 23: Employing push technology on devices and phones with azure mobile services

Windwos Phone Tile - Back

BackTitle. A string displayed at the bottom of the back of a Tile. The BackTitle must fit on a single line of text and should not be wider than the actual Tile. Approximately 15 characters will fit in the title before being truncated.

BackBackgroundImage. An image displayed on the back of the Tile.

BackContent. A string displayed in the body of the back of a Tile. Approximately 40 characters will fit in the Tile before being truncated.

Page 24: Employing push technology on devices and phones with azure mobile services

Windows Phone Raw• Push data to your application

• If app is not currently running MPNS discards the message.

RAW notificatio

n

Page 25: Employing push technology on devices and phones with azure mobile services

Create MPNS Notification Client

1. Create a Channel URI for the particular APP for handshaking.

2. Send the App URI to the server for registration

3. Server keeps track to all the URI sent from the Client

4. Server requests the Live services with the unique URI to Push data to the client

5. When Client receives the notification, it will invoke the PushChannel_ShellToastNotificationReceived for Toast Notifications

HttpNotificationChannel httpchannel = new HttpNotificationChannel(channelName);

Page 26: Employing push technology on devices and phones with azure mobile services

Demo

Page 27: Employing push technology on devices and phones with azure mobile services
Page 28: Employing push technology on devices and phones with azure mobile services
Page 29: Employing push technology on devices and phones with azure mobile services

Why Mobile Services ?

Very Easy to implement, everything is in built

Fast development

Solid Foundation as it uses SQL Database for storage

Scalability of App

Step by step source code from the portal

Supports multiple platforms like Andorid, IOS with source code.

Page 30: Employing push technology on devices and phones with azure mobile services

Watch the Demo

Page 31: Employing push technology on devices and phones with azure mobile services

Resources

Register your apphttp://manage.dev.live.com/build

Download the Windows Azure Toolkit for Windows 8 http://WATWindows8.codeplex.com

Download the Windows Azure Toolkit for Windows Phone http://WATwp.codeplex.com

Windows 8 Developer Documentationhttp://dev.windows.com

Page 32: Employing push technology on devices and phones with azure mobile services

Connect Me for more. Email : [email protected] : @abhi2434Websites: http://www.abhisheksur.com

http://www.dailydotnettips.com

Community : KolkataGeeks

http://www.kolkatageeks.com

Have a nice day ahead !!