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

fix(android): sending data to topic #821

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions notify/notification_fcm.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,6 @@ func GetAndroidNotification(req *PushNotification) []*messaging.Message {
}
}

// Check if the notification is a topic
if req.IsTopic() {
message := &messaging.Message{
Notification: req.Notification,
Android: req.Android,
Webpush: req.Webpush,
APNS: req.APNS,
FCMOptions: req.FCMOptions,
Topic: req.Topic,
Condition: req.Condition,
}

messages = append(messages, message)
}

var data map[string]string
if len(req.Data) > 0 {
data = make(map[string]string, len(req.Data))
Expand All @@ -170,6 +155,26 @@ func GetAndroidNotification(req *PushNotification) []*messaging.Message {
}
}

// Check if the notification is a topic
if req.IsTopic() {
message := &messaging.Message{
Notification: req.Notification,
Android: req.Android,
Webpush: req.Webpush,
APNS: req.APNS,
FCMOptions: req.FCMOptions,
Topic: req.Topic,
Condition: req.Condition,
}

// Add another field
if len(req.Data) > 0 {
message.Data = data
}

messages = append(messages, message)
}

// Loop through the tokens and create a message for each one
for _, token := range req.Tokens {
message := &messaging.Message{
Expand Down
Loading