Firebase Cloud Messaging无法解析主题名称 [英] Firebase Cloud Messaging Cannot parse topic name

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

问题描述

我正在尝试在我的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.

推荐答案

>主题名称中不允许使用/字符.

允许的字符是:

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

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

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 Cloud Messaging无法解析主题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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