Firebase 云消息传递无法解析主题名称 [英] Firebase Cloud Messaging Cannot parse topic name

查看:22
本文介绍了Firebase 云消息传递无法解析主题名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 iOS 应用中订阅一个主题,但不断收到错误消息:

I'm trying to subscribe to a topic in my iOS app, but keep getting the error:

<FIRMessaging/WARNING> Cannot parse topic name /topics/pets/cnlLksAxmdYPkDjEftDwZjFwvDw2_coffee. Will not subscribe.

我要订阅的代码是这样的:

The code I'm trying to subscribe with is this:

FIRMessaging.messaging().subscribe(toTopic: "/topics/pets/(name)")

其中 name 是您在错误中看到的主题的最后一部分.

where name is the last part of the topic you see in the error.

有人知道我做错了什么吗?我已经确认 Firebase 消息可以正确接收通知.

Does anybody know what I'm doing wrong? I've already confirmed Firebase messaging is correctly receiving notifications and all.

推荐答案

/ 字符不是 主题名称 允许的字符.

The / character is not an allowed character for a topic name.

允许的字符是:

  • a-z
  • A-Z
  • 0-9
  • -, _, ., ~, %
  • a-z
  • A-Z
  • 0-9
  • -, _, ., ~, %

我可以通过在 Android 中使用主题名称为 pets/123asd 和显示的日志进行测试来确认这些是唯一允许的字符:

I can confirm these are the only allowed characters by testing in Android with a topic name of pets/123asd and the logs shown:

Invalid topic name: Pets/123asd does not match the allowed format [a-zA-Z0-9-_.~%]{1,900}

对于 iOS,前缀 /topics/ 是必需的,并且仍然有效.无效字符仅适用于您在前缀后包含的主题名称.

For iOS, the prefix /topics/ is needed and is still valid. The invalid characters only apply to the topic name you include after the prefix.

这篇关于Firebase 云消息传递无法解析主题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆