I can send an FCM message to my Flutter app when the app has subscribed to "test_fcm_topic" as a topic. But if I subscribe to anything else IE: "redrobin" I don't receive the notification. I've tried sending from both the Flutter app and from Postman. In both cases the terminal shows the instance is received but there is no sound or notification popup.
I'm completely baffled as to why I cannot change the topic to anything other than "test_fcm_topic". Why would it work with one topic but not in the other? How can I even begin to troubleshoot?
Here's the code I use to subscribe;
FCMConfig.init(onBackgroundMessage: firebaseMessagingBackgroundHandler).then((value) {FCMConfig.subscribeToTopic("test_fcm_topic");});
Here's the send code in Flutter;
void send() async {
await http.post(
'https://fcm.googleapis.com/fcm/send',
headers: <String, String>{
'Content-Type': 'application/json',
'Authorization': 'key=$serverToken',
},
body: jsonEncode(
<String, dynamic>{
'notification': <String, dynamic>{
'body': 'This is a body',
'title': 'Banana'
},
'priority': 'high',
'data': <String, dynamic>{
"key_1" : "Value for key_1",
"key_2" : "Value for key_2"
},
'to': '/topics/test_fcm_topic',
},
),
);
}
For Postman I use these key pairs in the headers
Key: Authorization Value: key= server key
Key: Content-Type: Value: application/json
And this is the Raw JSON Body;
{
"to" : "/topics/test_fcm_topic",
"collapse_key" : "type_a",
"notification" : {
"body" : "Body of Your Notification",
"title": "Banana"
},
"data" : {
"body" : "This is a body",
"title": "Title of Your Notification in Title",
"key_1" : "Value for key_1",
"key_2" : "Value for key_2"
}
}