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)")
where name
is the last part of the topic you see in the error.
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.
Characters allowed are:
-
, _
, .
, ~
, %
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}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With