I'm developing a service for handling push notifications that integrates with Firebase cloud messaging. When I send a new message and specify a device token, it works fine. I get the notification title, body etc. However, when I specifiy a device group ID (which I get as a response when I register a new group with the device token), the device gets a notification, but it's blank - only showing the "from" field which is the sender ID. None of the notification title, body etc. show.
Code for message construction
func FcmNewMessage(title, body, collapseKey, token string) *messaging.Message {
oneHour := time.Duration(1) * time.Hour
message := &messaging.Message{
Notification: &messaging.Notification{
Title: title,
Body: body,
},
Android: &messaging.AndroidConfig{
TTL: &oneHour,
CollapseKey: collapseKey,
},
APNS: &messaging.APNSConfig{
Headers: map[string]string{
"apns-collapse-id": collapseKey,
},
},
Webpush: &messaging.WebpushConfig{
Notification: &messaging.WebpushNotification{
Icon: "https://my-server/icon.png",
},
Headers: map[string]string{
"urgency": "high",
"topic": collapseKey,
},
},
Token: token,
}
return message
}
As you can see above - "token" argument can either be a device token or a device group notification key token. It's when the device group token is used that there is issues.
Below are the client notifications:
When using the device token:
{
"from": "53xxxxxxxxxx",
"priority": "high",
"notification": {
"title": "test",
"body": "test",
"icon": "https://my-server/icon.png"
},
"collapse_key": "collapseMe"
}
When using device group token:
{
"from": "53xxxxxxxxxx"
}
I should also mention that when a device group token is used, the response I get from FCM is:
projects/projectid-123/messages/
So there is no message ID at the end. Normally the response would be:
projects/projectid-123/messages/<messageId>