diff --git a/go.mod b/go.mod index 2177f4f..4dad61a 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/apex/gateway v1.1.1 github.com/appleboy/com v0.0.2 github.com/appleboy/gin-status-api v1.1.0 - github.com/appleboy/go-fcm v0.1.4 + github.com/appleboy/go-fcm v0.1.5 github.com/appleboy/gofight/v2 v2.1.2 github.com/asdine/storm v2.1.2+incompatible github.com/aws/aws-lambda-go v1.13.3 // indirect @@ -55,4 +55,5 @@ require ( gopkg.in/go-playground/validator.v9 v9.30.2 // indirect gopkg.in/redis.v5 v5.2.9 gopkg.in/yaml.v2 v2.2.7 // indirect + honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect ) diff --git a/gorush/notification.go b/gorush/notification.go index c7d068e..61a5516 100644 --- a/gorush/notification.go +++ b/gorush/notification.go @@ -62,6 +62,7 @@ type PushNotification struct { Platform int `json:"platform" binding:"required"` Message string `json:"message,omitempty"` Title string `json:"title,omitempty"` + Image string `json:"image,omitempty"` Priority string `json:"priority,omitempty"` ContentAvailable bool `json:"content_available,omitempty"` MutableContent bool `json:"mutable_content,omitempty"` @@ -95,6 +96,7 @@ type PushNotification struct { Development bool `json:"development,omitempty"` SoundName string `json:"name,omitempty"` SoundVolume float32 `json:"volume,omitempty"` + Apns D `json:"apns,omitempty"` } // WaitDone decrements the WaitGroup counter. diff --git a/gorush/notification_fcm.go b/gorush/notification_fcm.go index d6202e6..6ff6284 100644 --- a/gorush/notification_fcm.go +++ b/gorush/notification_fcm.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - fcm "github.com/appleboy/go-fcm" + "github.com/appleboy/go-fcm" "github.com/sirupsen/logrus" ) @@ -72,11 +72,21 @@ func GetAndroidNotification(req PushNotification) *fcm.Message { notification.Notification.Title = req.Title } + if len(req.Image) > 0 { + notification.Notification.Image = req.Image + } + if v, ok := req.Sound.(string); ok && len(v) > 0 { notification.Notification.Sound = v } } + // handle iOS apns in fcm + + if len(req.Apns) > 0 { + notification.Apns = req.Apns + } + return notification }