0
votes

I've setup a Mobile App on Azure and configured push notifications with a newly created Notification Hub.

So far I have only implemented the iOS client, following the guides over here and it registers itself successfully. I can go over to the Azure Portal and send a test notification and sending from my own code also works.

In VS I inspected the registered devices and see the following:

enter image description here

Two registrations have been made, both for the same device (the PNS is the same), the registrations IDs are different.

If I test send via the portal, the message is delivered to the registration that says "Native". If I send via the backend, it will send to "Template".

  • What are these two registrations?
  • Why are different registrations used depending on where I send from?

To send the message from code I'm using:

var result = await hub.SendTemplateNotificationAsync(templateParams).ConfigureAwait(false);

And as mentioned above, the result details will show one successful delivery to the "Template" registration.

The client registers itself like this:

const string templateBodyAPNS = "{\"aps\":{\"alert\":\"$(messageParam)\"}}";

var templates = new JObject();
templates["genericMessage"] = new JObject
{
    {"body", templateBodyAPNS}
};

await push.RegisterAsync(deviceToken, templates);
1

1 Answers

2
votes

In order to receive push notifications devices we need to create one or more registrations in a notification hub. There are 2 main way for registering devices. Registry from the device directly to the notification hub and registering from your App Backend. We can get more info about registration management from the official document. If a device uses multiple Templates, then it must store one registration ID per template. The following is the snippet from the document

If you want to use Templates, each registration represents an individual template. This means that if your device uses two templates, you must register each template independently with its own PNS handle and set of tags. For native registrations (that is, without a template), registration methods for templates create or update existing registrations. To target different templates, you provide a template name when registering. You will provide different names if you want to maintain multiple templates for the same device.