Firebase 云消息传递无法解析主题名称

Firebase Cloud Messaging Cannot parse topic name(Firebase 云消息传递无法解析主题名称)
本文介绍了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 云消息传递无法解析主题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)