Skip to content

Commit 4e7850a

Browse files
Merge pull request #110652 from mikeparker104/patch-2
(AzureCXP) Include steps for token-based auth
2 parents cc1f38c + 0cfb1a9 commit 4e7850a

File tree

1 file changed

+76
-9
lines changed

1 file changed

+76
-9
lines changed

includes/notification-hubs-enable-apple-push-notifications.md

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,21 @@ To send push notifications to an iOS app, register your application with Apple,
6868

6969
4. In the **Certificates, Identifiers & Profiles** page, under **Identifiers**, locate the App ID line item that you just created, and select its row to display the **Edit your App ID Configuration** screen.
7070

71-
5. Scroll down to the checked **Push Notifications** option, and then select **Configure** to create the certificate.
71+
## Creating a Certificate for Notification Hubs
72+
A certificate is required to enable the notification hub to work with **APNS**. This can be done in one of two ways:
73+
74+
1. Create a **.p12** that can be uploaded directly to Notification Hub.
75+
2. Create a **.p8** that can be used for [token-based authentication](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-http2-token-authentification) (*the newer approach*).
76+
77+
The newer approach has a number of benefits (compared to using certificates) as documented in [Token-based (HTTP/2) authentication for APNS](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-http2-token-authentification). However, steps have been provided for both approaches.
78+
79+
### OPTION 1: Creating a .p12 push certificate that can be uploaded directly to Notification Hub
80+
81+
1. Scroll down to the checked **Push Notifications** option, and then select **Configure** to create the certificate.
7282

7383
![Edit App ID page](./media/notification-hubs-enable-apple-push-notifications/notification-hubs-edit-appid.png)
7484

75-
6. The **Apple Push Notification service SSL Certificates** window appears. Select the **Create Certificate** button under the **Development SSL Certificate** section.
85+
2. The **Apple Push Notification service SSL Certificates** window appears. Select the **Create Certificate** button under the **Development SSL Certificate** section.
7686

7787
![Create certificate for App ID button](./media/notification-hubs-enable-apple-push-notifications/notification-hubs-appid-create-cert.png)
7888

@@ -81,9 +91,9 @@ To send push notifications to an iOS app, register your application with Apple,
8191
> [!NOTE]
8292
> This tutorial uses a development certificate. The same process is used when registering a production certificate. Just make sure that you use the same certificate type when sending notifications.
8393
84-
1. Select **Choose File**, browse to the location where you saved the CSR file from the first task, and then double-click the certificate name to load it. Then select **Continue**.
94+
3. Select **Choose File**, browse to the location where you saved the CSR file from the first task, and then double-click the certificate name to load it. Then select **Continue**.
8595

86-
1. After the portal creates the certificate, select the **Download** button. Save the certificate, and remember the location to which it's saved.
96+
4. After the portal creates the certificate, select the **Download** button. Save the certificate, and remember the location to which it's saved.
8797

8898
![Generated certificate download page](./media/notification-hubs-enable-apple-push-notifications/notification-hubs-appid-download-cert.png)
8999

@@ -94,14 +104,14 @@ To send push notifications to an iOS app, register your application with Apple,
94104
> [!NOTE]
95105
> By default, the downloaded development certificate is named **aps_development.cer**.
96106
97-
1. Double-click the downloaded push certificate **aps_development.cer**. This action installs the new certificate in the Keychain, as shown in the following image:
107+
5. Double-click the downloaded push certificate **aps_development.cer**. This action installs the new certificate in the Keychain, as shown in the following image:
98108

99109
![Keychain access certificates list showing new certificate](./media/notification-hubs-enable-apple-push-notifications/notification-hubs-cert-in-keychain.png)
100110

101111
> [!NOTE]
102112
> Although the name in your certificate might be different, the name will be prefixed with **Apple Development iOS Push Services**.
103113
104-
1. In Keychain Access, right-click the new push certificate that you created in the **Certificates** category. Select **Export**, name the file, select the **.p12** format, and then select **Save**.
114+
6. In Keychain Access, right-click the new push certificate that you created in the **Certificates** category. Select **Export**, name the file, select the **.p12** format, and then select **Save**.
105115

106116
![Export certificate as p12 format](./media/notification-hubs-enable-apple-push-notifications/notification-hubs-export-cert-p12.png)
107117

@@ -110,6 +120,45 @@ To send push notifications to an iOS app, register your application with Apple,
110120
> [!NOTE]
111121
> Your .p12 file name and location might be different than what is pictured in this tutorial.
112122
123+
### OPTION 2: Creating a .p8 certificate that can be used for token-based authentication
124+
125+
1. Make note of the following details:
126+
127+
- **App ID Prefix** (this is a **Team ID**)
128+
- **Bundle ID**
129+
130+
2. Back in **Certificates, Identifiers & Profiles**, click **Keys**.
131+
132+
> [!NOTE]
133+
> If you already have a key configured for **APNS**, you can re-use the .p8 certificate that you downloaded right after it was created. If so, you can ignore steps **3** through **5**.
134+
135+
3. Click the **+** button (or the **Create a key** button) to create a new key.
136+
4. Provide a suitable **Key Name** value, then check the **Apple Push Notifications service (APNs)** option, and then click **Continue**, followed by **Register** on the next screen.
137+
5. Click **Download** and then move the **.p8** file (prefixed with *AuthKey_*) to a secure local directory, then click **Done**.
138+
139+
> [!NOTE]
140+
> Be sure to keep your .p8 file in a secure place (and save a backup). After downloading your key, it cannot be re-downloaded as the server copy is removed.
141+
142+
6. On **Keys**, click on the key that you just created (or an existing key if you have chosen to use that instead).
143+
7. Make note of the **Key ID** value.
144+
8. Open your .p8 certificate in a suitable application of your choice such as [**Visual Studio Code**](https://code.visualstudio.com) then make note of the key value. This is the value between **-----BEGIN PRIVATE KEY-----** and **-----END PRIVATE KEY-----** .
145+
146+
```
147+
-----BEGIN PRIVATE KEY-----
148+
<key_value>
149+
-----END PRIVATE KEY-----
150+
```
151+
152+
> [!NOTE]
153+
> This is the **token value** that will be used later to configure **Notification Hub**.
154+
155+
At the end of these steps you should have the following information for use later in [Configure your notification hub with APNs information](#configure-your-notification-hub-with-apns-information):
156+
157+
- **Team ID** (see step 1)
158+
- **Bundle ID** (see step 1)
159+
- **Key ID** (see step 7)
160+
- **Token value** i.e. the .p8 key value (see step 8)
161+
113162
## Create a provisioning profile for the app
114163
115164
1. Return to the [iOS Provisioning Portal](https://go.microsoft.com/fwlink/p/?LinkId=272456), select **Certificates, Identifiers & Profiles**, select **Profiles** from the left menu, and then select **+** to create a new profile. The **Register a New Provisioning Profile** screen appears.
@@ -147,13 +196,18 @@ To send push notifications to an iOS app, register your application with Apple,
147196
148197
## Create a notification hub
149198
150-
In this section, you create a notification hub and configure authentication with APNs by using the .p12 push certificate that you previously created. If you want to use a notification hub that you've already created, you can skip to step 5.
199+
In this section, you create a notification hub and configure authentication with APNs by using either the .p12 push certificate or token-based authentication. If you want to use a notification hub that you've already created, you can skip to step 5.
151200
152201
[!INCLUDE [notification-hubs-portal-create-new-hub](notification-hubs-portal-create-new-hub.md)]
153202
154203
## Configure your notification hub with APNs information
155204
156-
1. Under **Notification Services**, select **Apple (APNS)**.
205+
Under **Notification Services**, select **Apple (APNS)** then follow the appropriate steps based on the approach you chose previously in the [Creating a Certificate for Notification Hubs](#creating-a-certificate-for-notification-hubs) section.
206+
207+
> [!NOTE]
208+
> Use the **Production** for **Application Mode** only if you want to send push notifications to users who purchased your app from the store.
209+
210+
### OPTION 1: Using a .p12 push certificate
157211
158212
1. Select **Certificate**.
159213
@@ -163,10 +217,23 @@ In this section, you create a notification hub and configure authentication with
163217
164218
1. If required, specify the correct password.
165219
166-
1. Select **Sandbox** mode. Use the **Production** mode only if you want to send push notifications to users who purchased your app from the store.
220+
1. Select **Sandbox** mode.
167221
168222
![Configure APNs certification in Azure portal](./media/notification-hubs-enable-apple-push-notifications/notification-hubs-apple-config-cert.png)
169223
170224
1. Select **Save**.
171225
226+
### OPTION 2: Using token-based authentication
227+
228+
1. Select **Token**.
229+
1. Enter the following values that you acquired earlier:
230+
231+
- **Key ID**
232+
- **Bundle ID**
233+
- **Team ID**
234+
- **Token**
235+
236+
1. Choose **Sandbox**
237+
1. Select **Save**.
238+
172239
You've now configured your notification hub with APNs. You also have the connection strings to register your app and send push notifications.

0 commit comments

Comments
 (0)