You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: includes/notification-hubs-enable-apple-push-notifications.md
+76-9Lines changed: 76 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,11 +68,21 @@ To send push notifications to an iOS app, register your application with Apple,
68
68
69
69
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.
70
70
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.
72
82
73
83

74
84
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.
76
86
77
87

78
88
@@ -81,9 +91,9 @@ To send push notifications to an iOS app, register your application with Apple,
81
91
> [!NOTE]
82
92
> 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.
83
93
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**.
85
95
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.
@@ -94,14 +104,14 @@ To send push notifications to an iOS app, register your application with Apple,
94
104
> [!NOTE]
95
105
> By default, the downloaded development certificate is named **aps_development.cer**.
96
106
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:
98
108
99
109

100
110
101
111
> [!NOTE]
102
112
> Although the name in your certificate might be different, the name will be prefixed with **Apple Development iOS Push Services**.
103
113
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**.
105
115
106
116

107
117
@@ -110,6 +120,45 @@ To send push notifications to an iOS app, register your application with Apple,
110
120
> [!NOTE]
111
121
> Your .p12 file name and location might be different than what is pictured in this tutorial.
112
122
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
+
113
162
## Create a provisioning profile for the app
114
163
115
164
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,
147
196
148
197
## Create a notification hub
149
198
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.
## Configure your notification hub with APNs information
155
204
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
157
211
158
212
1. Select **Certificate**.
159
213
@@ -163,10 +217,23 @@ In this section, you create a notification hub and configure authentication with
163
217
164
218
1. If required, specify the correct password.
165
219
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.
167
221
168
222

169
223
170
224
1. Select **Save**.
171
225
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
+
172
239
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