Skip to content

Commit

Permalink
Add notification message only on ios
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed Apr 16, 2024
1 parent ade6a2b commit a0d27dc
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions internal/notify/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"log"
"net/http"
"strings"

"github.com/appleboy/go-fcm"
"github.com/satimoto/go-datastore/pkg/util"
Expand All @@ -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)
Expand Down Expand Up @@ -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
}

0 comments on commit a0d27dc

Please sign in to comment.