简体   繁体   中英

Creating an installation with template on Azure NotificationHub generates 2 registrations

I'm creating an API to register a device (mobile app - push notification) into the Azure Notification Hubs using Installations, but every time that I create a new Installation with a template, it shows 2 registrations on the notification hub, one for FcmRegistrationDescription and other one for FcmTemplateRegistrationDescription .

Is that the expected behavior? Is there a way to register only the installation with the template?

private async Task CreateInstallation(string installationId, string pushChannel)
{
    Installation installation = new Installation();
    installation.InstallationId = installationId;
    installation.PushChannel = pushChannel;
    installation.Platform = NotificationPlatform.Fcm;
    installation.Tags = new List<string>() { "soccer" };

    string template = "{ \"data\": { \"message\": \"$(message)\", \"userstatus\": \"$(userstatus)\" }, \"priority\": \"high\" }";
    installation.Templates  = new Dictionary<string, InstallationTemplate>()
    {
        { "fcmTemplate" , new InstallationTemplate() { Body = template } }
    };

    await hub.CreateOrUpdateInstallationAsync(installation);
}

To receive push notifications devices its required to create one or more registrations in a notification hub. The two main patterns for registering devices: registering from the device directly to the notification hub, and registering through the application backend .

Suggest you to refer this detail document as mentioned below:

"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."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM