Open
Description
Describe your environment
- Operating System version: Multiple (Amazon Linux, Mac OS Ventura 13.0.1 (22A400))
- Firebase SDK version: Firebase Admin SDK v4
- Library version: v4.8.0
- Go version: 1.18
- Firebase Product: Firebase Cloud Messaging
Describe the problem
When sending a slice of FCM Messages via the messaging.SendAll() method, each device displays the same badge count, not the badge count specified in the device's FCM Message object.
Steps to reproduce:
- Create a slice of FCM Message objects, each with their own distinct badge counts.
- Send these FCM message objects via the SendAll() method.
- Each recipient device displays the same badge count, not the count specified in its corresponding FCM Message object.
Relevant Code:
// 1. Initialize the Messaging Client
ctx := context.Background()
messagingClient, err := fcmClient.firebaseApp.Messaging(ctx)
if err != nil {
return err
}
// 2. Create slice of FCM Messages, each with their own intended badge count.
fcmMessages := []*messaging.Message{}
for _, notif := range notifications {
fcmMessage := &messaging.Message{
Data: map[string]string{
// ...
"badge": notif.BadgeCountString,
},
APNS: &messaging.APNSConfig{
Payload: &messaging.APNSPayload{
Aps: &messaging.Aps{
// ...
Badge: ¬if.BadgeCount,
},
},
},
Token: notif.DeviceToken,
}
fcmMessages = append(fcmMessages, fcmMessage)
}
// 3. Use the SendAll method to send messages in parallel.
_, err = messagingClient.SendAll(ctx, fcmMessages)
// 4. (BUG) Upon receipt, each device displays the same badge count.