Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Firebase Cloud Messaging SendAll() sets same device badge count across different FCM Message objects #527

Open
sauceman40 opened this issue Dec 3, 2022 · 2 comments
Assignees

Comments

@sauceman40
Copy link

sauceman40 commented Dec 3, 2022

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: &notif.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.
@google-oss-bot
Copy link
Collaborator

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@sauceman40
Copy link
Author

@chong-shao @lahirumaramba is any more context needed here? Let me know whether you're able to reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants