Skip to content

Commit

Permalink
fix(android): sending data to topic (#821)
Browse files Browse the repository at this point in the history
fix #816
  • Loading branch information
iAbbos authored Dec 12, 2024
1 parent 1946e24 commit e66b985
Showing 1 changed file with 20 additions and 15 deletions.
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

0 comments on commit e66b985

Please sign in to comment.