首页 > 解决方案 > FCM Invalid topic name on base64 topic

问题描述

When I subscribe to a base64 (no padding) topic from my android app I get this exception

java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=321, result=0, data=null} to activity {com.example/com.example.view.activity.MainActivity}: 
java.lang.IllegalArgumentException: Invalid topic name: aHR0cDovL3d3dy5iYmMuY28udWsvbmV3cy8
                   does not match the allowed format [a-zA-Z0-9-_.~%]{1,900}

The topic name is supposed to pass the given exp so I don't know why I get this exception, also the topic doesn't exist yet. The console confirms that no topics exist yet, but when I send a message to the said topic it appears as completed.From the app I can subscribe to topics like "afsfsfsggg" .

Sending a message from the Admin SDK gives this response but no entries in the console:

projects/project-id/messages/5312412342391596688

标签: androidfirebasefirebase-cloud-messaging

解决方案


问题是换行符“\n”。

topic.replace("\n", "");

推荐阅读