Skip to content

Commit cf18689

Browse files
committed
fix: sending data to topic
1 parent d0e1045 commit cf18689

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

notify/notification_fcm.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,6 @@ func GetAndroidNotification(req *PushNotification) []*messaging.Message {
140140
}
141141
}
142142

143-
// Check if the notification is a topic
144-
if req.IsTopic() {
145-
message := &messaging.Message{
146-
Notification: req.Notification,
147-
Android: req.Android,
148-
Webpush: req.Webpush,
149-
APNS: req.APNS,
150-
FCMOptions: req.FCMOptions,
151-
Topic: req.Topic,
152-
Condition: req.Condition,
153-
}
154-
155-
messages = append(messages, message)
156-
}
157-
158143
var data map[string]string
159144
if len(req.Data) > 0 {
160145
data = make(map[string]string, len(req.Data))
@@ -170,6 +155,26 @@ func GetAndroidNotification(req *PushNotification) []*messaging.Message {
170155
}
171156
}
172157

158+
// Check if the notification is a topic
159+
if req.IsTopic() {
160+
message := &messaging.Message{
161+
Notification: req.Notification,
162+
Android: req.Android,
163+
Webpush: req.Webpush,
164+
APNS: req.APNS,
165+
FCMOptions: req.FCMOptions,
166+
Topic: req.Topic,
167+
Condition: req.Condition,
168+
}
169+
170+
// Add another field
171+
if len(req.Data) > 0 {
172+
message.Data = data
173+
}
174+
175+
messages = append(messages, message)
176+
}
177+
173178
// Loop through the tokens and create a message for each one
174179
for _, token := range req.Tokens {
175180
message := &messaging.Message{

0 commit comments

Comments
 (0)