简体   繁体   English

在 Azure NotificationHub 上使用模板创建安装会生成 2 个注册

[英]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 .我正在创建一个 API 以使用安装将设备(移动应用程序 - 推送通知)注册到 Azure 通知中心,但每次我使用模板创建新Installation时,它都会在通知中心显示 2 个注册,一个用于FcmRegistrationDescription另一个是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. “如果你想使用模板,每个注册代表一个单独的模板。这意味着如果你的设备使用两个模板,你必须使用自己的 PNS 句柄和一组标签独立地注册每个模板。

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."如果您想为同一设备维护多个模板,您将提供不同的名称。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以通过 NotificationHub Azure 中的 registrationId 发送通知吗? - I can send notification by registrationId in NotificationHub Azure? Azure Notificationhub-PN发送在沙盒中工作,但不在生产中 - Azure Notificationhub - PN send working in sandbox but not in production Microsoft.Azure.NotificationHub-同步方法中的异步调用 - Microsoft.Azure.NotificationHub - Async call in sync method 使用DryIoc创建具有多个服务注册的单例 - Creating a Singleton with Multiple Service Registrations Using DryIoc 无法从.NET控制台应用程序向(Android)设备传递Azure NotificationHub推送消息 - Failing to deliver Azure NotificationHub push messages to (Android) devices from .NET console app Azure 应用程序注册 - C# 应用程序的 SQL Server 权限 - Azure app registrations - SQL Server permission for C# App 如何在Azure通知中心上更新多个设备注册 - How can I update multiple device registrations on Azure notification hub 无法检索从Azure Notification Hub创建的注册的指标 - Unable to retrieve metrics for Registrations Created from Azure Notification Hub 生成令牌但不执行 azure url - Generates the token but does not execute the azure url Razor Engine:生成和生成&的模板中的URL生成 - Razor Engine: URL generation in template of & generates &amp;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM