diff --git a/notify/notification_fcm.go b/notify/notification_fcm.go index 054ab64d..3598858d 100644 --- a/notify/notification_fcm.go +++ b/notify/notification_fcm.go @@ -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)) @@ -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{