Azure / azure-notificationhubs-dotnet

.NET SDK for Azure Notification Hubs
MIT License
70 stars 122 forks source link

Installation Template Headers #147

Open Talento90 opened 4 years ago

Talento90 commented 4 years ago

Hello, I am trying to use Installations to register my devices, since it's the recommended way to do it. The problem is that for IOS templates, it requires headers { "apns-push-type", "background" }. I can see a property headers in the TemplateInstallation but it's specific for MPNS notifications... Are there any way to inject template headers during the creation of an installation?

var installation = new Installation
{
    InstallationId = installationId,
    Platform = platform,
    PushChannel = pushChannel,
    Tags = tags,
    Templates = new Dictionary<string, InstallationTemplate>()
};

foreach (var template in templates)
{
    installation.Templates.Add(template.Name, new InstallationTemplate
    {
        Body = template.Template,
        Headers = //  Gets or set collection of headers applicable for MPNS-targeted notifications
    });
}

My current strategy is when a customer login in the application we always remove the old registrations and create a new one. Is that a bad practice? Are there any limit for registrations related with the same device token?

Thanks in advance :)

marstr commented 4 years ago

I can see a property headers in the TemplateInstallation but it's specific for MPNS notifications... Are there any way to inject template headers during the creation of an installation?

This is outdated documentation. It used to be that the only platform that we accepted/needed headers for was MPNS, but that has changed now. We should update that language to make it more clear.

My current strategy is when a customer login in the application we always remove the old registrations and create a new one. Is that a bad practice?

This seems like a reasonable strategy to me. Though I'd be curious to hear from other folks regarding their approaches.

Are there any limit for registrations related with the same device token?

There is no such limitation.

marstr commented 4 years ago

I'm going to keep this issue open until we've fixed that documentation.

Tommigun1980 commented 3 years ago

Hi @marstr. The documentation needs to be up to date as us developers must be able to trust it. Any chance the documentation could be updated at some point as this ticket as been open since August 2020? How are we supposed to know when something changes unless the documentation is updated? It's no use for you to add new features and remove limitations unless the documentation is updated, as developers won't know about them.