Firebase Cloud Messaging Unable to parse topic name

I'm trying to subscribe to a topic in my iOS application, 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 is as follows:

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

where nameis the last part of the topic that you see in the error.

Does anyone know what I'm doing wrong? I have already confirmed that Firebase messages correctly receive notifications and that’s it.

+4
source share
1 answer

The character is /not a valid character for the topic name.

Allowed characters:

  • ah
  • AZ
  • 0-9
  • -, _, ., ~,%

, , Android pets/123asd :

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

iOS /topics/ . , .

+10

Source: https://habr.com/ru/post/1673365/


All Articles