[英]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.