簡體   English   中英

在 Azure NotificationHub 上使用模板創建安裝會生成 2 個注冊

[英]Creating an installation with template on Azure NotificationHub generates 2 registrations

我正在創建一個 API 以使用安裝將設備(移動應用程序 - 推送通知)注冊到 Azure 通知中心,但每次我使用模板創建新Installation時,它都會在通知中心顯示 2 個注冊,一個用於FcmRegistrationDescription另一個是FcmTemplateRegistrationDescription

這是預期的行為嗎? 有沒有辦法只用模板注冊安裝?

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);
}

要接收推送通知設備,需要在通知中心創建一個或多個注冊。 注冊設備的兩種主要模式:從設備直接注冊到通知中心,以及通過應用程序后端注冊

建議您參考以下詳細文檔

“如果你想使用模板,每個注冊代表一個單獨的模板。這意味着如果你的設備使用兩個模板,你必須使用自己的 PNS 句柄和一組標簽獨立地注冊每個模板。

對於本機注冊(即沒有模板),模板的注冊方法創建或更新現有注冊。 要針對不同的模板,請在注冊時提供模板名稱。 如果您想為同一設備維護多個模板,您將提供不同的名稱。”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM