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

53 lines
1.2 KiB
Go
Raw Normal View History

package requestBody
2021-12-09 15:43:36 +08:00
import (
"Open_IM/pkg/common/config"
)
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"`
2022-06-02 18:17:11 +08:00
Extras Extras `json:"extras"`
}
type Ios struct {
2022-06-02 18:36:42 +08:00
Alert string `json:"alert,omitempty"`
Sound string `json:"sound,omitempty"`
Badge string `json:"badge,omitempty"`
Extras Extras `json:"extras"`
MutableContent bool `json:"mutable-content"`
2022-06-02 18:17:11 +08:00
}
type Extras struct {
ClientMsgID string `json:"clientMsgID"`
}
2022-04-13 16:20:30 +08:00
func (n *Notification) SetAlert(alert string) {
n.Alert = alert
2022-04-13 16:20:30 +08:00
n.Android.Alert = alert
n.SetAndroidIntent()
n.IOS.Alert = alert
n.IOS.Sound = "default"
n.IOS.Badge = "+1"
2022-06-02 18:17:11 +08:00
}
2022-04-13 16:20:30 +08:00
2022-06-02 18:17:11 +08:00
func (n *Notification) SetExtras(extras Extras) {
n.IOS.Extras = extras
n.Android.Extras = extras
}
2022-06-02 18:17:11 +08:00
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
}
2022-06-02 18:36:42 +08:00
func (n *Notification) IOSEnableMutableContent() {
n.IOS.MutableContent = true
}