You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase Messaging主题格式错误问题求助

Firebase Cloud Messaging主题条件错误修复方案
  • 核心问题:你误用了Message类的属性——Topic字段仅支持单个主题名称,多主题的OR/AND条件必须使用Condition字段,而非Topic。

  • 错误原因:你把拼接好的多主题条件字符串赋值给了Topic,这不符合FCM的API规范,导致操作失败。你的条件字符串格式本身是正确的('主题ID' in topics用||连接),问题出在属性匹配错误。

  • 修正后的代码:

new Message()
{
    Data = new Dictionary<string, string>
    {
        ["Sound"] = SoundName, 
        ["UseSound"] = string.IsNullOrWhiteSpace(SoundName) ? "false" : "true",
    },
    Notification = new Notification
    {
        Title = $"{Interest.ToTitleCase()}Update",
        Body = Title
    },
    // 将条件字符串赋值给Condition字段
    Condition = string.Join(" || ", Tags.Select(t => $"'{t}' in topics")) 
};

内容的提问来源于stack exchange,提问作者Mr.Deer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 23:54:07