Files
open-im-server/internal/push/jpush/requestBody/notification.go
T

42 lines
931 B
Go
Raw Normal View History

package requestBody
2021-12-09 15:43:36 +08:00
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
)
2021-11-12 16:09:21 +08:00
type Notification struct {
2021-11-12 18:15:28 +08:00
Alert string `json:"alert,omitempty"`
Android Android `json:"android,omitempty"`
IOS Ios `json:"ios,omitempty"`
}
type Android struct {
2021-11-12 18:15:28 +08:00
Alert string `json:"alert,omitempty"`
2021-11-12 17:59:37 +08:00
Intent struct {
URL string `json:"url,omitempty"`
} `json:"intent,omitempty"`
}
type Ios struct {
2021-12-09 15:43:36 +08:00
Alert string `json:"alert,omitempty"`
Sound string `json:"sound,omitempty"`
Badge string `json:"badge,omitempty"`
}
2021-12-09 15:43:36 +08:00
func (n *Notification) SetAlert(alert, platform string) {
n.Alert = alert
2021-12-09 15:43:36 +08:00
switch platform {
case constant.AndroidPlatformStr:
n.Android.Alert = alert
n.SetAndroidIntent()
case constant.IOSPlatformStr:
n.IOS.Alert = alert
n.IOS.Sound = "default"
n.IOS.Badge = "+1"
default:
}
}
2021-11-12 16:09:21 +08:00
func (n *Notification) SetAndroidIntent() {
2021-11-12 17:59:37 +08:00
n.Android.Intent.URL = config.Config.Push.Jpns.PushIntent
2021-11-12 16:09:21 +08:00
}