快速入门:在通知中心设置推送通知Quickstart: Set up push notifications in a notification hub

Azure 通知中心提供了一种易于使用且可扩展的推送引擎。使用通知中心可将通知发送到任意平台(iOS、Android、Windows 和百度),也可从任意后端(云或本地)进行发送。Azure Notification Hubs provides a push engine that's easy to use and that scales out. Use Notification Hubs to send notifications to any platform (iOS, Android, Windows, Baidu) and from any back end (cloud or on-premises). 有关详细信息,请参阅什么是 Azure 通知中心?For more information, see What is Azure Notification Hubs?.

在该快速入门中,你将在通知中心使用平台通知系统 (PNS) 设置在多个平台上设置推送通知。In this quickstart, you'll use the platform notification system (PNS) settings in Notification Hubs to set up push notifications on multiple platforms. 该快速入门介绍了要在 Azure 门户中执行的步骤。The quickstart shows you the steps to take in the Azure portal.

如果尚未创建通知中心,请立即创建。If you haven't already created a notification hub, create one now. 有关详细信息,请参阅在 Azure 门户中创建 Azure 通知中心使用 Azure CLI 创建 Azure 通知中心For more information, see Create an Azure notification hub in the Azure portal or Create an Azure notification hub using the Azure CLI.

Apple Push Notification 服务Apple Push Notification Service

要设置 Apple Push Notification 服务 (APNS):To set up Apple Push Notification Service (APNS):

  1. 在 Azure 门户的“通知中心”页上,从左侧菜单中选择“Apple (APNS)”。In the Azure portal, on the Notification Hub page, select Apple (APNS) from the left menu.

  2. 对于“身份验证模式”,请选择“证书”或“令牌” 。For Authentication Mode, select either Certificate or Token.

    a.a. 如果选择“证书”:If you select Certificate:

    • 选择文件图标,再选择要上传的 .p12 文件。Select the file icon, and then select the .p12 file you want to upload.

    • 输入密码。Enter a password.

    • 选择“沙盒”模式。Select Sandbox mode. 要将推送通知发送给从应用商店购买应用的用户,则选择“生产”模式。Or, to send push notifications to users who purchased your app from the store, select Production mode.

      Azure 门户中 APNS 证书配置的屏幕截图

    b.b. 如果选择“令牌”:If you select Token:

    • 输入“密钥 ID”、“绑定 ID”、“团队 ID”和“令牌”的值 。Enter the values for Key ID, Bundle ID, Team ID, and Token.

    • 选择“沙盒”模式。Select Sandbox mode. 要将推送通知发送给从应用商店购买应用的用户,则选择“生产”模式。Or, to send push notifications to users who purchased your app from the store, select Production mode.

      Azure 门户中 APNS 令牌配置的屏幕截图

有关详细信息,请参阅使用 Azure 通知中心向 iOS 应用发送推送通知For more information, see Send push notifications to iOS apps using Azure Notification Hubs.

Windows 推送通知服务Windows Push Notification Service

要设置 Windows 推送通知服务 (WNS):To set up Windows Push Notification Service (WNS):

  1. 在 Azure 门户的“通知中心”页上,从左侧菜单中选择“Windows (WNS)”。In the Azure portal, on the Notification Hub page, select Windows (WNS) from the left menu.

  2. 输入“包 SID”和“安全密钥”的值。Enter values for Package SID and Security Key.

  3. 选择“保存” 。Select Save.

    显示“包 SID”框和“安全密钥”框的屏幕截图

相关信息,请参阅通过 Azure 通知中心向 UWP 发送通知For information, see Send notifications to UWP apps by using Azure Notification Hubs.

面向 Windows Phone 的 Microsoft 推送通知服务Microsoft Push Notification Service for Windows Phone

要为 Windows Phone 设置 Microsoft 推送通知服务 (MPNS):To set up Microsoft Push Notification Service (MPNS) for Windows Phone:

  1. 在 Azure 门户的“通知中心”页上,从左侧菜单中选择“Windows Phone (MPNS)”。In the Azure portal, on the Notification Hub page, select Windows Phone (MPNS) from the left menu.

  2. 启用未经身份验证或经过身份验证的推送通知:Enable either unauthenticated or authenticated push notifications:

    a.a. 要启用未经身份验证的推送通知,请选择“启用未经身份验证的推送” > “保存” 。To enable unauthenticated push notifications, select Enable unauthenticated push > Save.

    显示如何启用未经身份验证的推送的屏幕截图

    b.b. 要启用经过身份验证的推送通知:To enable authenticated push notifications:

    • 在工具栏上选择“上传证书”。On the toolbar, select Upload Certificate.
    • 选择文件图标,然后选择证书文件。Select the file icon, and then select the certificate file.
    • 输入证书的密码。Enter the password for the certificate.
    • 选择“确定”。Select OK.
    • 在“Windows Phone (MPNS)”页上选择“保存”。On the Windows Phone (MPNS) page, select Save.

有关详细信息,请参阅通过通知中心向 Windows Phone 应用推送通知For more information, see Push notifications to Windows Phone apps by using Notification Hubs.

Baidu (Android China)Baidu (Android China)

要为百度设置推送通知:To set up push notifications for Baidu:

  1. 在 Azure 门户的“通知中心”页上,从左侧菜单中选择“Baidu (Android China)”。In the Azure portal, on the Notification Hub page, select Baidu (Android China) from the left menu.

  2. 在百度云推送项目中,输入从百度控制台获得的 API 密钥。Enter the API Key that you obtained from the Baidu console in the Baidu cloud push project.

  3. 在百度云推送项目中,输入从百度控制台获得的机密密钥。Enter the Secret Key that you obtained from the Baidu console in the Baidu cloud push project.

  4. 选择“保存”。Select Save.

    显示百度 (Android China) 推送通知配置的通知中心屏幕截图

完成这些步骤后,会显示一条警报,指出已成功上传通知中心。When you complete these steps, an alert indicates that the notification hub has been successfully updated. “保存”按钮已禁用。The Save button is disabled.

有关详细信息,请参阅借助百度的通知中心入门For more information, see Get started with Notification Hubs by using Baidu.

后续步骤Next steps

在该快速入门中,你学习了如何在 Azure 门户中为通知中心配置平台通知系统设置。In this quickstart, you learned how to configure platform notification system settings for a notification hub in the Azure portal.

要详细了解如何将通知推送到各类平台,请参阅以下教程:To learn more about how to push notifications to various platforms, see these tutorials: