firebase / firebase/firebase-admin-go
BUG: Firebase Cloud Messaging SendAll() sets same device badge count across different FCM Message objects
- Dominant language
- Go
- Stars
- 1.3k
- Forks
- 274
- Avg merge
- 10h 39m
- Merged PRs (30d)
- 2
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:
1. Create a slice of FCM Message objects, each with their own distinct badge counts.
2. Send these FCM message objects via the SendAll() method.
3. 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.
```
Contributor guide
Assessment
This issue has not been assessed yet.