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

53 lines
1.2 KiB
Go
Raw Normal View History

2023-06-30 09:45:02 +08:00
package body
2023-06-29 22:35:31 +08:00
import (
2023-06-30 09:45:02 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
2023-06-29 22:35:31 +08:00
)
type Notification struct {
Alert string `json:"alert,omitempty"`
Android Android `json:"android,omitempty"`
IOS Ios `json:"ios,omitempty"`
}
type Android struct {
Alert string `json:"alert,omitempty"`
Intent struct {
URL string `json:"url,omitempty"`
} `json:"intent,omitempty"`
2023-06-30 09:45:02 +08:00
Extras Extras `json:"extras"`
2023-06-29 22:35:31 +08:00
}
type Ios struct {
2023-06-30 09:45:02 +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"`
}
type Extras struct {
ClientMsgID string `json:"clientMsgID"`
2023-06-29 22:35:31 +08:00
}
func (n *Notification) SetAlert(alert string) {
n.Alert = alert
n.Android.Alert = alert
n.SetAndroidIntent()
n.IOS.Alert = alert
n.IOS.Sound = "default"
n.IOS.Badge = "+1"
2023-06-30 09:45:02 +08:00
}
2023-06-29 22:35:31 +08:00
2023-06-30 09:45:02 +08:00
func (n *Notification) SetExtras(extras Extras) {
n.IOS.Extras = extras
n.Android.Extras = extras
2023-06-29 22:35:31 +08:00
}
2023-06-30 09:45:02 +08:00
2023-06-29 22:35:31 +08:00
func (n *Notification) SetAndroidIntent() {
n.Android.Intent.URL = config.Config.Push.Jpns.PushIntent
}
2023-06-30 09:45:02 +08:00
func (n *Notification) IOSEnableMutableContent() {
n.IOS.MutableContent = true
}