Can Poyrazoğlu Can Poyrazoğlu - 1 year ago 123
C# Question

How to setup Azure Notification Hub in C# backend

I'm trying to implement my C# backend's communication with Notification Hub. I've read almost every tutorial about Azure Notification Hub, and I can't find a decent tutorial that explains what actually corresponds to what. I think there are two ways of representing a device (from what I've understood): an Installation and Registration, and Installation seems to be newer and more preferred.

However, when I get into Installation, I get more questions in my mind:

What is

? Is it something that I create, or something that I get from somewhere, either device or PNS.

Do I need to set up
, or does it default to longest (it says 90 days is the longest)? What if I want it to be longer than 90 days?

What is
? Is it, just like
, something that I create, or get from somewhere?

How are templates exactly used?

Out of all these variables, which one is the actual device push token that I get at the client?

I usually don't ask those kind of questions that seek for a tutorial-ish answers and have multiple questions, but I've tried to search everywhere, but the more I search, the more it gets complicated and I don't even know where to start. Any answer would be a good starting point to anyone trying to learn Notification Hubs, just like me.

Answer Source

InstallationId is an abstraction on top of device token/key/channel etc. It's a unique id that you create when you 'install' a device (or user if your OS/platform allows separate tokens for multiple users). This is an id you can use to associate tags, templates etc with the device. You create an installation once and then keep the id somewhere in the local storage and then make updates to the installation associated with the id if you need to.

You don't need to explicitly set ExpirationDate. I think in the past tokens on most platforms used to expire, so this was a way to let Notification Hubs know when not to try to push to the token. I believe now it's not the case. So what happens is if Notification Hubs cannot deliver a notification to a device for a number of times, it just deletes the registration by itself.

Has this post on templates been useful?

PushChannel stands for 'The channel URI if registering the installation for WNS; Device Token if registering for APNS.'

Let me know in the comments if I can clarify any of these and I'll update the answer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download