Skip to content

Commit 87b3d3d

Browse files
authored
Merge pull request #99216 from sethmanheim/syntax
Add language specifiers per GH issue #44743, also misc cleanup
2 parents f19348b + b5978da commit 87b3d3d

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

articles/notification-hubs/notification-hubs-push-notification-registration-management.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ ms.workload: mobile
1313
ms.tgt_pltfrm: mobile-multiple
1414
ms.devlang: dotnet
1515
ms.topic: article
16-
ms.date: 04/08/2019
16+
ms.date: 12/17/2019
1717
ms.author: sethm
1818
ms.reviewer: jowargo
1919
ms.lastreviewed: 04/08/2019
2020
---
2121

2222
# Registration management
2323

24-
## Overview
25-
2624
This topic explains how to register devices with notification hubs in order to receive push notifications. The topic describes registrations at a high level, then introduces the two main patterns for registering devices: registering from the device directly to the notification hub, and registering through an application backend.
2725

2826
## What is device registration
@@ -38,15 +36,15 @@ A registration associates the Platform Notification Service (PNS) handle for a d
3836
3937
### Installations
4038

41-
An Installation is an enhanced registration that includes a bag of push related properties. It is the latest and best approach to registering your devices. However, it is not supported by client-side .NET SDK ([Notification Hub SDK for backend operations](https://www.nuget.org/packages/Microsoft.Azure.NotificationHubs/)) as of yet. This means if you are registering from the client device itself, you would have to use the [Notification Hubs REST API](https://docs.microsoft.com/rest/api/notificationhubs/create-overwrite-installation) approach to support installations. If you are using a backend service, you should be able to use [Notification Hub SDK for backend operations](https://www.nuget.org/packages/Microsoft.Azure.NotificationHubs/).
39+
An Installation is an enhanced registration that includes a bag of push related properties. It is the latest and best approach to registering your devices. However, it is not supported by client-side .NET SDK ([Notification Hub SDK for backend operations](https://www.nuget.org/packages/Microsoft.Azure.NotificationHubs/)) as of yet. This means if you are registering from the client device itself, you would have to use the [Notification Hubs REST API](/rest/api/notificationhubs/create-overwrite-installation) approach to support installations. If you are using a backend service, you should be able to use [Notification Hub SDK for backend operations](https://www.nuget.org/packages/Microsoft.Azure.NotificationHubs/).
4240

4341
The following are some key advantages to using installations:
4442

4543
- Creating or updating an installation is fully idempotent. So you can retry it without any concerns about duplicate registrations.
4644
- The installation model supports a special tag format (`$InstallationId:{INSTALLATION_ID}`) that enables sending a notification directly to the specific device. For example, if the app's code sets an installation ID of `joe93developer` for this particular device, a developer can target this device when sending a notification to the `$InstallationId:{joe93developer}` tag. This enables you to target a specific device without having to do any additional coding.
4745
- Using installations also enables you to do partial registration updates. The partial update of an installation is requested with a PATCH method using the [JSON-Patch standard](https://tools.ietf.org/html/rfc6902). This is useful when you want to update tags on the registration. You don't have to pull down the entire registration and then resend all the previous tags again.
4846

49-
An installation can contain the following properties. For a complete listing of the installation properties, see [Create or Overwrite an Installation with REST API](https://docs.microsoft.com/rest/api/notificationhubs/create-overwrite-installation) or [Installation Properties](https://docs.microsoft.com/dotnet/api/microsoft.azure.notificationhubs.installation).
47+
An installation can contain the following properties. For a complete listing of the installation properties, see [Create or Overwrite an Installation with REST API](/rest/api/notificationhubs/create-overwrite-installation) or [Installation Properties](/dotnet/api/microsoft.azure.notificationhubs.installation).
5048

5149
```json
5250
// Example installation format to show some supported properties
@@ -96,7 +94,7 @@ Registrations and installations must contain a valid PNS handle for each device/
9694

9795
If you want to use [Templates](notification-hubs-templates-cross-platform-push-messages.md), the device installation also holds all templates associated with that device in a JSON format (see sample above). The template names help target different templates for the same device.
9896

99-
Each template name maps to a template body and an optional set of tags. Moreover, each platform can have additional template properties. For Windows Store (using WNS) and Windows Phone 8 (using MPNS), an additional set of headers can be part of the template. In the case of APNs, you can set an expiry property to either a constant or to a template expression. For a complete listing of the installation properties see, [Create or Overwrite an Installation with REST](https://docs.microsoft.com/rest/api/notificationhubs/create-overwrite-installation) topic.
97+
Each template name maps to a template body and an optional set of tags. Moreover, each platform can have additional template properties. For Windows Store (using WNS) and Windows Phone 8 (using MPNS), an additional set of headers can be part of the template. In the case of APNs, you can set an expiry property to either a constant or to a template expression. For a complete listing of the installation properties see, [Create or Overwrite an Installation with REST](/rest/api/notificationhubs/create-overwrite-installation) topic.
10098

10199
### Secondary Tiles for Windows Store Apps
102100

@@ -108,7 +106,7 @@ The SecondaryTiles dictionary uses the same TileId that is used to create the Se
108106

109107
When managing device registration from client apps, the backend is only responsible for sending notifications. Client apps keep PNS handles up-to-date, and register tags. The following picture illustrates this pattern.
110108

111-
![](./media/notification-hubs-registration-management/notification-hubs-registering-on-device.png)
109+
![Registration from device](./media/notification-hubs-registration-management/notification-hubs-registering-on-device.png)
112110

113111
The device first retrieves the PNS handle from the PNS, then registers with the notification hub directly. After the registration is successful, the app backend can send a notification targeting that registration. For more information about how to send notifications, see [Routing and Tag Expressions](notification-hubs-tags-segment-push-message.md).
114112

@@ -121,11 +119,11 @@ Registering from the device is the simplest method, but it has some drawbacks:
121119

122120
### Example code to register with a notification hub from a device using an installation
123121

124-
At this time, this is only supported using the [Notification Hubs REST API](https://docs.microsoft.com/rest/api/notificationhubs/create-overwrite-installation).
122+
At this time, this is only supported using the [Notification Hubs REST API](/rest/api/notificationhubs/create-overwrite-installation).
125123

126124
You can also use the PATCH method using the [JSON-Patch standard](https://tools.ietf.org/html/rfc6902) for updating the installation.
127125

128-
```
126+
```csharp
129127
class DeviceInstallation
130128
{
131129
public string installationId { get; set; }
@@ -206,7 +204,7 @@ else
206204

207205
These methods create or update a registration for the device on which they are called. This means that in order to update the handle or the tags, you must overwrite the entire registration. Remember that registrations are transient, so you should always have a reliable store with the current tags that a specific device needs.
208206

209-
```
207+
```csharp
210208
// Initialize the Notification Hub
211209
NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(listenConnString, hubName);
212210

@@ -261,7 +259,7 @@ catch (Microsoft.WindowsAzure.Messaging.RegistrationGoneException e)
261259

262260
Managing registrations from the backend requires writing additional code. The app from the device must provide the updated PNS handle to the backend every time the app starts (along with tags and templates), and the backend must update this handle on the notification hub. The following picture illustrates this design.
263261

264-
![](./media/notification-hubs-registration-management/notification-hubs-registering-on-backend.png)
262+
![Registration management](./media/notification-hubs-registration-management/notification-hubs-registering-on-backend.png)
265263

266264
The advantages of managing registrations from the backend include the ability to modify tags to registrations even when the corresponding app on the device is inactive, and to authenticate the client app before adding a tag to its registration.
267265

@@ -271,7 +269,7 @@ The client device still gets its PNS handle and relevant installation properties
271269

272270
You can also use the PATCH method using the [JSON-Patch standard](https://tools.ietf.org/html/rfc6902) for updating the installation.
273271

274-
```
272+
```csharp
275273
// Initialize the Notification Hub
276274
NotificationHubClient hub = NotificationHubClient.CreateClientFromConnectionString(listenConnString, hubName);
277275

@@ -317,7 +315,7 @@ public async Task<HttpResponseMessage> Put(DeviceInstallation deviceUpdate)
317315

318316
From your app backend, you can perform basic CRUDS operations on registrations. For example:
319317

320-
```
318+
```csharp
321319
var hub = NotificationHubClient.CreateClientFromConnectionString("{connectionString}", "hubName");
322320

323321
// create a registration description object of the correct type, e.g.

0 commit comments

Comments
 (0)