PUSH NOTIFICATIONS in Word

Drawer QR Code 2d barcode in Word PUSH NOTIFICATIONS

CHAPTER 17 PUSH NOTIFICATIONS
Paint Denso QR Bar Code In None
Using Barcode creation for Office Word Control to generate, create QR Code image in Word applications.
www.OnBarcode.com
QR Creator In None
Using Barcode maker for Microsoft Word Control to generate, create Denso QR Bar Code image in Office Word applications.
www.OnBarcode.com
Add the following code to the sendPushNotificationToClient function: private void sendPushNotificationToClient(string url) { HttpWebRequest sendNotificationRequest = (HttpWebRequest)WebRequest.Create(url); sendNotificationRequest.Method = "POST"; sendNotificationRequest.Headers = new WebHeaderCollection(); sendNotificationRequest.ContentType = "text/xml"; sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "toast"); sendNotificationRequest.Headers.Add("X-NotificationClass", "2"); string str = string.Format(TilePushXML, txtTitle.Text, txtText.Text); byte[] strBytes = new UTF8Encoding().GetBytes(str); sendNotificationRequest.ContentLength = strBytes.Length; using (Stream requestStream = sendNotificationRequest.GetRequestStream()) { requestStream.Write(strBytes, 0, strBytes.Length); } try {
Barcode Generator In None
Using Barcode generator for Word Control to generate, create Barcode image in Microsoft Word applications.
www.OnBarcode.com
GTIN - 12 Creation In None
Using Barcode generator for Office Word Control to generate, create UPC-A Supplement 2 image in Office Word applications.
www.OnBarcode.com
HttpWebResponse response = (HttpWebResponse)sendNotificationRequest.GetResponse(); string notificationStatus = response.Headers["X-NotificationStatus"]; string deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"]; lblStatus.Text = "Status: " + notificationStatus + " : " + deviceConnectionStatus; } catch (Exception ex) { //handle 404 (URI not found) and other exceptions that may occur lblStatus.Text = "Failed to connect, exception detail: " + ex.Message; } Note that the TilePushXML variable has been previously defined when we talked about Tile Notifications specifically, in the Creating an Application to Send Notifications section. With the WCF service tracking subscribed clients and sending push notifications complete, it is now time to enhance the client application to call the web service with its push notification URL.
Encoding Code 39 Extended In None
Using Barcode maker for Word Control to generate, create Code 39 image in Word applications.
www.OnBarcode.com
Creating Barcode In None
Using Barcode generator for Office Word Control to generate, create Barcode image in Microsoft Word applications.
www.OnBarcode.com
CHAPTER 17 PUSH NOTIFICATIONS
Code 128B Maker In None
Using Barcode generator for Microsoft Word Control to generate, create Code-128 image in Word applications.
www.OnBarcode.com
Postnet Generation In None
Using Barcode creator for Office Word Control to generate, create Postnet image in Office Word applications.
www.OnBarcode.com
Figure 17 10. Main application form with Broadcast button
QR Code ISO/IEC18004 Drawer In Java
Using Barcode maker for Android Control to generate, create QR Code image in Android applications.
www.OnBarcode.com
Recognize QR Code JIS X 0510 In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Modifying the Client to Call the WCF Service
Barcode Recognizer In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Barcode Creation In None
Using Barcode printer for Online Control to generate, create Barcode image in Online applications.
www.OnBarcode.com
The Windows Phone 7 Push Notification client application needs to be modified to call the newly implemented web service with the push notification URL. Previously, we briefly mentioned that the convenience of creating a RESTful WCF service lies in the fact that the operations of that web service can be accessed as URLs. For instance, the URL http://localhost/RegistrationService/ Register uri={0} accesses the Register function of the web service created in the previous section; the uri parameter is supplied on the QueryString. With that in mind, you can go ahead and complete the Windows Phone 7 Push Notification client implementation by creating the functions that will register/unregister a Windows Phone 7 client with the server: 1. 2. Launch Visual Studio 2010 Express for Windows Phone and open the PNClient project. Locate the ChannelUri property getter and setter and change them to the following (notice the use of two new functions, RegisterUriWithServer and UnregisterUriFromServer). public Uri ChannelUri { get { return channelUri; } set { //unregister the old URI from the server if (channelUri!=null) UnregisterUriFromServer(channelUri); //register the new URI with the server RegisterUriWithServer(value);
Barcode Generation In Java
Using Barcode printer for Eclipse BIRT Control to generate, create Barcode image in BIRT reports applications.
www.OnBarcode.com
Paint QR Code In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
www.OnBarcode.com
CHAPTER 17 PUSH NOTIFICATIONS
Barcode Creator In Java
Using Barcode printer for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
GTIN - 128 Creator In None
Using Barcode maker for Online Control to generate, create GS1 128 image in Online applications.
www.OnBarcode.com
channelUri = value; OnChannelUriChanged(value); } } 3. Now add the following two functions to invoke the WCF service that you have created (note that when it comes time to release your service to production, you will be most likely deploying this service somewhere in the cloud). private void RegisterUriWithServer(Uri newChannelUri) { //Hardcode for solution - need to be updated in case the REST WCF service address change string baseUri = "http://localhost/RegistrationService/Register uri={0}"; string theUri = String.Format(baseUri, newChannelUri.ToString()); WebClient client = new WebClient(); client.DownloadStringCompleted += (s, e) => { if (e.Error == null) Dispatcher.BeginInvoke(() => { txtURI.Text = "changing uri to " + newChannelUri.ToString(); }); else Dispatcher.BeginInvoke(() => { txtURI.Text = "registration failed " + e.Error.Message; }); }; client.DownloadStringAsync(new Uri(theUri)); } private void UnregisterUriFromServer(Uri oldChannelUri) { //Hardcode for solution - need to be updated in case the REST WCF service address change string baseUri = "http://localhost/RegistrationService/Unregister uri={0}"; string theUri = String.Format(baseUri, oldChannelUri.ToString()); WebClient client = new WebClient(); client.DownloadStringCompleted += (s, e) => { if (e.Error == null) Dispatcher.BeginInvoke(() => { txtURI.Text = "unregistered uri " + oldChannelUri.ToString(); }); else Dispatcher.BeginInvoke(() => { txtURI.Text = "registration delete failed " + e.Error.Message; }); }; client.DownloadStringAsync(new Uri(theUri)); }
Barcode Generation In Objective-C
Using Barcode maker for iPad Control to generate, create Barcode image in iPad applications.
www.OnBarcode.com
Decoding UPC-A Supplement 5 In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
CHAPTER 17 PUSH NOTIFICATIONS
Drawing Barcode In Visual Basic .NET
Using Barcode drawer for .NET framework Control to generate, create Barcode image in .NET framework applications.
www.OnBarcode.com
Making Code39 In Java
Using Barcode drawer for Android Control to generate, create Code-39 image in Android applications.
www.OnBarcode.com
In the preceding code, notice that the URL of the cloud is hard-coded this URL must match the URL you have specified in the configuration file (app.config) for the WCF service. Notice also how the event handlers (client.DownloadStringCompleted) are wired up those event handlers provide the status updates on whether the registration/unregistration succeeded or failed. At this point, you have completed writing both the server and the client piece for automated push notification. It is now time to verify that the server is able to keep track and notify its clients appropriately, without the need to manually copy and paste the push notification URL.
Copyright © OnBarcode.com . All rights reserved.