Skip to content

Commit a4c71fc

Browse files
authored
Merge pull request #108719 from dbradish-microsoft/dbradish_notificationHubs2
added Azure CLI syntax for Google FCM
2 parents 1a2c230 + 2bdb060 commit a4c71fc

File tree

3 files changed

+74
-26
lines changed

3 files changed

+74
-26
lines changed

articles/notification-hubs/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
href: create-notification-hub-portal.md
1414
- name: Create a notification hub - Azure CLI
1515
href: create-notification-hub-azure-cli.md
16-
- name: Configure a notification hub - Azure portal
16+
- name: Configure a notification hub
1717
href: configure-notification-hub-portal-pns-settings.md
1818
- name: Tutorials
1919
items:

articles/notification-hubs/configure-notification-hub-portal-pns-settings.md

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to set up Azure Notification Hubs in the Azure portal by
44
services: notification-hubs
55
author: sethmanheim
66
manager: femila
7-
editor: jwargo
7+
editor: dbradish-microsoft
88

99
ms.service: notification-hubs
1010
ms.workload: mobile
@@ -15,13 +15,13 @@ ms.reviewer: jowargo
1515
ms.lastreviewed: 02/14/2019
1616
---
1717

18-
# Set up push notifications in a notification hub in the Azure portal
18+
# Quickstart: Set up push notifications in a notification hub
1919

2020
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). For more information, see [What is Azure Notification Hubs?](notification-hubs-push-notification-overview.md).
2121

22-
In this quickstart, you'll use the platform notification system (PNS) settings in Notification Hubs to set up push notifications on multiple platforms. The quickstart shows you the steps to take in the Azure portal.
22+
In this quickstart, you'll use the platform notification system (PNS) settings in Notification Hubs to set up push notifications on multiple platforms. The quickstart shows you the steps to take in the Azure portal. [Google Firebase Cloud Messaging](/azure/notification-hubs/configure-notification-hub-portal-pns-settings?tabs=azure-cli#google-firebase-cloud-messaging-fcm) includes instructions for using the Azure CLI.
2323

24-
If you haven't already created a notification hub, create one now. For more information, see [Create an Azure notification hub in the Azure portal](create-notification-hub-portal.md).
24+
If you haven't already created a notification hub, create one now. For more information, see [Create an Azure notification hub in the Azure portal](create-notification-hub-portal.md) or [Create an Azure notification hub using the Azure CLI](create-notification-hub-azure-cli.md)
2525

2626
## Apple Push Notification Service
2727

@@ -47,19 +47,67 @@ To set up Apple Push Notification Service (APNS):
4747

4848
For more information, see [Push notifications to iOS by using Azure Notification Hubs](notification-hubs-ios-apple-push-notification-apns-get-started.md).
4949

50-
## Google Firebase Cloud Messaging
50+
## Google Firebase Cloud Messaging (FCM)
5151

52-
To set up push notifications for Google Firebase Cloud Messaging (FCM):
52+
# [Portal](#tab/azure-portal)
5353

54-
1. In the Azure portal, on the **Notification Hub** page, select **Google (GCM/FCM)** from the left menu.
55-
2. Paste the **API Key** for the FCM project that you saved earlier.
56-
3. Select **Save**.
54+
To set up push notifications for Google FCM:
55+
56+
1. In the Azure portal, on the **Notification Hub** page, select **Google (GCM/FCM)** from the left menu.
57+
2. Paste the **API Key** for the Google FCM project that you saved earlier.
58+
3. Select **Save**.
5759

5860
![Screenshot that shows how to configure Notification Hubs for Google FCM](./media/notification-hubs-android-push-notification-google-fcm-get-started/fcm-server-key.png)
5961

60-
When you complete these steps, an alert indicates that the notification hub has been successfully updated. The **Save** button is disabled.
62+
When you complete these steps, an alert indicates that the notification hub has been successfully updated. The **Save** button is disabled.
63+
64+
# [Azure CLI](#tab/azure-cli)
65+
66+
### Prerequisites
67+
68+
Before you begin, you must have the following:
69+
70+
* The [Azure CLI](/cli/azure/install-azure-cli) version 2.0.67 or later.
71+
72+
* The Azure CLI [extension for Notification Hubs](/cli/azure/ext/notification-hub/notification-hub).
73+
* The **API Key** for a Google Firebase Cloud Messaging (FCM) project.
74+
75+
### Set up push notifications for Google FCM
76+
77+
1. Use the [az notification-hub credential gcm update](/cli/azure/ext/notification-hub/notification-hub/credential/gcm#ext-notification-hub-az-notification-hub-credential-gcm-update) command to add your Google API Key to your notification hub.
78+
79+
```azurecli
80+
az notification-hub credential gcm update --resource-group spnhubrg --namespace-name spnhubns --notification-hub-name spfcmtutorial1nhub --google-api-key myKey
81+
```
82+
83+
2. The Android App needs a connection string to connect with the notification hub. Use the [az notification-hub authorization-rule list](/cli/azure/ext/notification-hub/notification-hub/authorization-rule#ext-notification-hub-az-notification-hub-authorization-rule-list) command to list the available access policies. Use the [az notification-hub authorization-rule list-keys](/cli/azure/ext/notification-hub/notification-hub/authorization-rule#ext-notification-hub-az-notification-hub-authorization-rule-list-keys) command to get the access policy connection strings. Specify the **primaryConnectionString** or **secondaryConnectionString** in the `--query` parameter to get the primary connection string directly.
6184

62-
For more information, see [Push notifications to Android devices by using Notification Hubs and Google FCM](notification-hubs-android-push-notification-google-fcm-get-started.md).
85+
```azurecli
86+
#list access policies for a notification hub
87+
az notification-hub authorization-rule list --resource-group spnhubrg --namespace-name spnhubns --notification-hub-name spfcmtutorial1nhub --output table
88+
89+
#list keys and connection strings for a notification hub access policy
90+
az notification-hub authorization-rule list-keys --resource-group spnhubrg --namespace-name spnhubns --notification-hub-name spfcmtutorial1nhub --name myAccessPolicyName --output json
91+
92+
#get the primaryConnectionString for an access policy
93+
az notification-hub authorization-rule list-keys --resource-group spnhubrg --namespace-name spnhubns --notification-hub-name spfcmtutorial1nhub --name myAccessPolicyName --query primaryConnectionString
94+
```
95+
96+
3. Use the [az notification-hub test-send](/cli/azure/ext/notification-hub/notification-hub#ext-notification-hub-az-notification-hub-test-send) command to test sending messages to the Android App.
97+
98+
```azurecli
99+
#test with message body
100+
az notification-hub test-send --resource-group spnhubrg --namespace-name spnhubns --notification-hub-name spfcmtutorial1nhub --notification-format gcm --message "my message body"
101+
102+
#test with JSON string
103+
az notification-hub test-send --resource-group spnhubrg --namespace-name spnhubns --notification-hub-name spfcmtutorial1nhub --notification-format gcm --payload "{\"data\":{\"message\":\"my JSON string\"}}"
104+
```
105+
106+
Get Azure CLI references for other platforms with the [az notification-hub credential](/cli/azure/ext/notification-hub/notification-hub/credential) command.
107+
108+
---
109+
110+
For more information on pushing notifications to an Android application, see [Send push notifications to Android devices using Firebase](notification-hubs-android-push-notification-google-fcm-get-started.md).
63111

64112
## Windows Push Notification Service
65113

@@ -75,7 +123,7 @@ For information, see [Send notifications to UWP apps by using Azure Notification
75123

76124
## Microsoft Push Notification Service for Windows Phone
77125

78-
To set up Microsoft Push Notification Service (MPNS) for Windows Phone:
126+
To set up Microsoft Push Notification Service (MPNS) for Windows Phone:
79127

80128
1. In the Azure portal, on the **Notification Hub** page, select **Windows Phone (MPNS)** from the left menu.
81129
1. Enable either unauthenticated or authenticated push notifications:
@@ -92,30 +140,30 @@ To set up Microsoft Push Notification Service (MPNS) for Windows Phone:
92140
* On the **Windows Phone (MPNS)** page, select **Save**.
93141

94142
For more information, see [Push notifications to Windows Phone apps by using Notification Hubs](notification-hubs-windows-mobile-push-notifications-mpns.md).
95-
96143

97144
## Baidu (Android China)
98145

99146
To set up push notifications for Baidu:
100147

101-
1. In the Azure portal, on the **Notification Hub** page, select **Baidu (Android China)** from the left menu.
102-
2. Enter the **Api Key** that you obtained from the Baidu console in the Baidu cloud push project.
103-
3. Enter the **Secret Key** that you obtained from the Baidu console in the Baidu cloud push project.
104-
4. Select **Save**.
148+
1. In the Azure portal, on the **Notification Hub** page, select **Baidu (Android China)** from the left menu.
149+
2. Enter the **Api Key** that you obtained from the Baidu console in the Baidu cloud push project.
150+
3. Enter the **Secret Key** that you obtained from the Baidu console in the Baidu cloud push project.
151+
4. Select **Save**.
105152

106153
![Screenshot of Notification Hubs that shows the Baidu (Android China) configuration for push notifications](./media/notification-hubs-baidu-get-started/AzureNotificationServicesBaidu.png)
107154

108-
When you complete these steps, an alert indicates that the notification hub has been successfully updated. The **Save** button is disabled.
155+
When you complete these steps, an alert indicates that the notification hub has been successfully updated. The **Save** button is disabled.
109156

110157
For more information, see [Get started with Notification Hubs by using Baidu](notification-hubs-baidu-china-android-notifications-get-started.md).
111158

112159
## Next steps
113-
In this quickstart, you learned how to configure platform notification system settings for a notification hub in the Azure portal.
160+
161+
In this quickstart, you learned how to configure platform notification system settings for a notification hub in the Azure portal.
114162

115163
To learn more about how to push notifications to various platforms, see these tutorials:
116164

117-
- [Push notifications to iOS devices by using Notification Hubs and APNS](notification-hubs-ios-apple-push-notification-apns-get-started.md)
118-
- [Push notifications to Android devices by using Notification Hubs and Google FCM](notification-hubs-android-push-notification-google-fcm-get-started.md)
119-
- [Push notifications to a UWP app running on a Windows device](notification-hubs-windows-store-dotnet-get-started-wns-push-notification.md)
120-
- [Push notifications to a Windows Phone 8 app by using MPNS](notification-hubs-windows-mobile-push-notifications-mpns.md)
121-
- [Push notifications by using Notification Hubs and Baidu cloud push](notification-hubs-baidu-china-android-notifications-get-started.md)
165+
-[Push notifications to iOS devices by using Notification Hubs and APNS](notification-hubs-ios-apple-push-notification-apns-get-started.md)
166+
-[Push notifications to Android devices by using Notification Hubs and Google FCM](notification-hubs-android-push-notification-google-fcm-get-started.md)
167+
-[Push notifications to a UWP app running on a Windows device](notification-hubs-windows-store-dotnet-get-started-wns-push-notification.md)
168+
-[Push notifications to a Windows Phone 8 app by using MPNS](notification-hubs-windows-mobile-push-notifications-mpns.md)
169+
-[Push notifications by using Notification Hubs and Baidu cloud push](notification-hubs-baidu-china-android-notifications-get-started.md)

articles/notification-hubs/create-notification-hub-portal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.reviewer: jowargo
1515
ms.lastreviewed: 02/14/2019
1616
---
1717

18-
# Create an Azure notification hub in the Azure portal
18+
# Quickstart: Create an Azure notification hub in the Azure portal
1919
Azure Notification Hubs provide an easy-to-use and scaled-out push engine that allows you to send notifications to any platform (iOS, Android, Windows, Kindle, Baidu, etc.) from any backend (cloud or on-premises). For more information about the service, see [What is Azure Notification Hubs?](notification-hubs-push-notification-overview.md).
2020

2121
In this quickstart, you create a notification hub in the Azure portal. The first section gives you steps to create a Notification Hubs namespace and a hub in that namespace. The second section gives you steps to create a notification hub in an existing Notification Hubs namespace.

0 commit comments

Comments
 (0)