From a0d27dcce82aa42dc318da61b3f2d0f0ca95414f Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Tue, 16 Apr 2024 15:06:35 +0200 Subject: [PATCH] Add notification message only on ios --- internal/notify/request.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/notify/request.go b/internal/notify/request.go index 6a064dd..f91c6df 100644 --- a/internal/notify/request.go +++ b/internal/notify/request.go @@ -5,6 +5,7 @@ import ( "io" "log" "net/http" + "strings" "github.com/appleboy/go-fcm" "github.com/satimoto/go-datastore/pkg/util" @@ -16,7 +17,7 @@ type Notifier interface { func (r *NotifyResolver) PostNotify(rw http.ResponseWriter, request *http.Request) { token := request.URL.Query().Get("token") - platform := request.URL.Query().Get("platform") + platform := request.URL.Query().Get("platform") appData := util.NilString(request.URL.Query().Get("app_data")) notifyRequest, err := r.getNotifyRequest(request) @@ -94,16 +95,21 @@ func (r *NotifyResolver) getMessage(notification *Notification) *fcm.Message { data["app_data"] = *notification.AppData } - return &fcm.Message{ - To: notification.TargetIdentifier, - Notification: &fcm.Notification{ - Title: notification.DisplayMessage, - }, + message := fcm.Message{ + To: notification.TargetIdentifier, ContentAvailable: false, MutableContent: true, Priority: "high", Data: data, } + + if strings.EqualFold(notification.Type, "ios") { + message.Notification = &fcm.Notification{ + Title: notification.DisplayMessage, + } + } + + return &message } return nil }