您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

用于 .NET 的 Azure 通知中心库Azure Notification Hubs libraries for .NET

Azure 通知中心提供易用的多平台扩展式推送引擎。Azure Notification Hubs provide an easy-to-use, multi-platform, scaled-out push engine. 使用单个跨平台 API 调用,即可轻松地从任意云或本地后端向任意移动平台发送有针对性的个性化推送通知。With a single cross-platform API call, you can easily send targeted and personalized push notifications to any mobile platform from any cloud or on-premises backend.

客户端库Client library

直接从 Visual Studio 包管理器控制台或使用 .NET Core CLI 安装 NuGet 包Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.

备注

Azure 通知中心 NuGet 包现在支持 .NET Standard,以允许在通知中心后端使用 .NET CoreThe Azure Notification Hubs NuGet package now supports .NET Standard, which allows using .NET core for backend use of Notifications Hubs

Visual Studio 包管理器Visual Studio Package Manager

Install-Package Microsoft.Azure.NotificationHubs
dotnet add package Microsoft.Azure.NotificationHubs

代码示例Code Example

此示例连接到通知中心,并发送 Windows 推送通知服务 (WNS) 消息。This example connects to a Notification Hub and sends a Windows Push Notification Service (WNS) message.

NotificationHubClient hub = NotificationHubClient
                                .CreateClientFromConnectionString("<connection string with full access>", "<hub name>");
string toast = @"<toast><visual><binding template=""ToastText01""><text id=""1"">Hello from a .NET App!</text></binding></visual></toast>";
await hub.SendWindowsNativeNotificationAsync(toast);

管理库Management library

直接从 Visual Studio 包管理器控制台或使用 .NET Core CLI 安装 NuGet 包Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.

Visual Studio 包管理器Visual Studio Package Manager

Install-Package Microsoft.Azure.Management.NotificationHubs
dotnet add package Microsoft.Azure.Management.NotificationHubs

示例Samples