简体   繁体   English

使用Azure的Windows 8和Windows Phone推送通知

[英]Windows 8 And Windows Phone Push Notifications Using Azure

I've looked into Azure Mobile Services and found its great but does not give me the flexibility I want (Node.js also leaves a bad taste in my mouth coming from C#). 我研究了Azure移动服务,发现它很棒,但没有给我我想要的灵活性(Node.js也让C#留下了不好的味道)。

I was using periodic update notifications in Windows 8 and already have an ASP.NET Web API project supplying tile images and tile xml content. 我在Windows 8中使用的是定期更新通知,并且已经有一个ASP.NET Web API项目提供图块图像和图块xml内容。 I was hoping to use an Azure Worker Role with Azure storage tables for Push Notifications for Windows 8 and Windows Phone. 我希望将Azure辅助角色与Azure存储表一起用于Windows 8和Windows Phone的推送通知。

I found this example but it seems to be for VS2012 Release Preview. 我找到了这个示例,但它似乎适用于VS2012 Release Preview。 I can't find an updated version or any other samples to work with. 我找不到要使用的更新版本或任何其他示例。 In particular I want my service to support both Windows 8 and Windows Phone. 我特别希望我的服务同时支持Windows 8和Windows Phone。

http://watwindows8.codeplex.com/wikipage?title=Push%20Notification%20Worker%20Sample http://watwindows8.codeplex.com/wikipage?title=Push%20Notification%20Worker%20Sample

If anyone can outline the references/nuget packages I need. 如果有人可以概述我需要的参考/ nuget包。 It would be a great help. 这将是一个很大的帮助。

EDIT: 编辑:

Jim O'Neil's blog is a good starting point. Jim O'Neil的博客是一个很好的起点。 I need to use a Azure Worker Role because I want to send my notifications periodically. 我需要使用Azure辅助角色,因为我想定期发送通知。

I also found the WnsRecipe NuGet package for sending push notifications from the server. 我还找到了用于从服务器发送推送通知的WnsRecipe NuGet软件包。 Jim O'Neil solution is just as good. Jim O'Neil的解决方案同样出色。

Finally, to save a bit of time, I was hoping to avoid writing data acess code for registering apps channel ID's to a table on the server. 最后,为了节省时间,我希望避免编写用于将应用程序通道ID注册到服务器上的表的数据访问代码。 The Azure Mobile Services MobileServiceClient class is a great solution to this as it lets you do all of this with a couple of lines of code. Azure移动服务MobileServiceClient类是一个很好的解决方案,因为它允许您使用几行代码来完成所有这些工作。 The table is available through REST services. 该表可通过REST服务获得。 However, questions remain: 但是,问题仍然存在:

  1. Can I continue using the Mobile Services Table Storage MobileServiceClient with my app and Azure Worker Role or do I have to use Azure Table Storage? 我可以继续将Mobile Services Table Storage MobileServiceClient与我的应用程序和Azure工作者角色一起使用,还是必须使用Azure Table Storage?
  2. If I can use MobileServiceClient, how do I access the table from my Azure Worker Role? 如果可以使用MobileServiceClient,如何从我的Azure Worker角色访问表?
  3. If I have to use Azure Table Storage which also provides a REST service for free, how can I access the table from my Windows 8 app? 如果必须使用还免费提供REST服务的Azure表存储,如何从Windows 8应用访问表?

Strictly speaking, no NuGet packages are needed, they are just wrappers for functionality (it's all REST/OAuth under the covers) to make your life easier. 严格来说,不需要NuGet软件包,它们只是功能的包装(所有内容均为REST / OAuth),使您的生活更轻松。 As you observed, the Windows Azure Toolkit for Windows 8 and Windows Phone has been somewhat supplanted by Windows Azure Mobile Services . 如您所见, Windows Azure Mobile Services已在某种程度上取代了Windows 8和Windows Phone的Windows Azure工具包

If you want to do it all yourself, you can check out a three part blog series I did on using Azure Web Sites for Push Notifications . 如果您想自己做所有事情,则可以查看一个由三部分组成的博客系列,有关我使用Azure网站进行推送通知所做的工作 It's Web Sites, not Web Roles, but that part is fairly interchangeable; 它是网站,而不是网站角色,但是那部分是可以互换的。 although, I'd say that Web Sites are going to be a far more economical option here unless you already have a service implemented that you are using. 不过,我要说的是,除非您已经实现了要使用的服务,否则网站将是一种更加经济的选择。

I don't have Windows Phone incorporated into that series, and Windows Phone does use a slightly different notification mechanism from Windows 8, but that's on my to-do list, and hopefully what is there will get you going in the right direction. 我没有将Windows Phone纳入该系列中,并且Windows Phone确实使用了与Windows 8稍有不同的通知机制,但这在我的待办事项清单上,希望在那里可以使您朝正确的方向前进。

When you use the MobileServiceClient to store data in Mobile Services, you are actually storing your data in a SQL Azure database. 当您使用MobileServiceClient在Mobile Services中存储数据时,实际上是在将数据存储在SQL Azure数据库中。 You have a number of options when it comes to accessing this data from your worker role. 从工作角色访问此数据时,您有许多选择。

  • Connect directly using a SQL client. 使用SQL客户端直接连接。 This could be Entity Framework, a different ORM, or even raw ADO.NET. 这可能是实体框架,其他ORM甚至是原始ADO.NET。 You can get the connection string for your database by selecting it in the Azure portal. 您可以通过在Azure门户中选择数据库来获取数据库的连接字符串。 On the dashboard tab there is an option to show connection strings. 在仪表板选项卡上,有一个显示连接字符串的选项。
  • Use a client library to access the data via Mobile Services. 使用客户端库通过移动服务访问数据。 Unfortunately we do not have an official SDK that can be used from a worker role yet but the good news is that there is an unofficial package on NuGet 不幸的是,我们还没有一个可以从工作角色使用的官方SDK,但是好消息是NuGet上有一个非官方的软件包
  • Access the data directly via the HTTP endpoint that Mobile Services provides by making HTTP requests. 通过发出HTTP请求,直接通过Mobile Services提供的HTTP端点访问数据。 The API is documented here . 该API 在此处记录

Windows Azure Service Bus just released a new feature that allows to push Windows 8 (and iOS) notifications from C# back-ends (and soon from Mobile Services too), with no need top handle ChannelURIs at all. Windows Azure Service Bus刚刚发布了一项新功能,该功能允许从C#后端(很快也从移动服务)推送Windows 8(和iOS)通知,根本不需要顶级句柄ChannelURI。

Take a look at: http://channel9.msdn.com/Shows/Cloud+Cover/Episode-100-Introduction-to-the-Windows-Azure-Service-Bus-Notification-Hubs 看看: http : //channel9.msdn.com/Shows/Cloud+Cover/Episode-100-Introduction-to-the-Windows-Azure-Service-Bus-Notification-Hubs

Windows 8 code walkthrough: http://channel9.msdn.com/Blogs/Subscribe/Service-Bus-Notification-Hubs-Code-Walkthrough-Windows-8-Edition Windows 8代码演练: http//channel9.msdn.com/Blogs/Subscribe/Service-Bus-Notification-Hubs-Code-Walkthrough-Windows-8-Edition

If you try it, let me know what you think! 如果您尝试一下,请告诉我您的想法!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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