简体   繁体   中英

Implementing live tile push notifications in a C# asmx webservice

I have an asmx web service that hosts various data, and now I want to send live tile updates from the web service. I have understood that push notifications can be sent from cloud to WSN, but I haven't really found any good examples for custom web services. Any ideas how this can be implemented?

In addition to the great references already provided I wanted to speak specifically to the use of " custom web services ." In a greenfield push notification scenario, I'd strongly recommend looking at Windows Azure Mobile Services (WAMS) which abstracts much of the underlying REST/HTTP/OAuth choreography AND provides the benefit that it's backed by the Windows Azure cloud architecture (pay for what you use, failover, data backup etc.)

Given you already have a service, you may or may not decide the benefits of WAMS are worth the code changes/migration it would require. Should you want to continue with the service you have, you will end up doing a bit of grunt work yourself - using OAuth to authenticate with WNS, etc. It's not rocket surgery, but it's tedious :) The Windows Azure Toolkit for Windows 8 did include a recipe for doing all that, but it's now deprecated by Windows Azure Mobile service.

I tackled the subject of doing the push notification flow from "scratch" leveraging ASP.NET (I used WebAPI but ASMX could be used as well) in Windows Azure Web Sites (which you might consider as a host for your service). There's a bit of ancillary work involved as you'll need somewhere to store the channel IDs for the notifications (I used the free MySQL instance) and you'll need to use OAuth to communicate to the WNS (I used a helper class posted as a Gist ), but I cover all that end-to-end in a three-part blog series

Your server infrastructure (Windows vs. Linux) and the type of application (asmx vs. aspx) don't really have any impact on how you send the notifications. Notifications are sent as an HTTP POST from your server to the MPNS server with specially formatted XML data.

Here are two really good references to get you started:

Push Notification Overview http://msdn.microsoft.com/en-us/library/windows/apps/hh913756.aspx

Sending Push Notifications http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh868244(v=win.10).aspx

Dev support, design support and more awesome goodness on the way: http://bit.ly/winappsupport

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM